Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yield until graph object update #366

Open
dphblox opened this issue Jul 15, 2024 · 2 comments
Open

Yield until graph object update #366

dphblox opened this issue Jul 15, 2024 · 2 comments
Labels
enhancement New feature or request not ready - evaluating Currently gauging feedback

Comments

@dphblox
Copy link

dphblox commented Jul 15, 2024

As part of the design of Eventuals (#4), Fusion is aiming to better support long-running imperative sequences embedded in a reactive system. As part of this, the process might wait for an object to change.

Right now, this would have to be implemented via polling:

scope:Eventual(function(use)
    repeat task.wait() until peek(state) == "foo"
end)

Ideally though, the change would be pushed to the imperative code:

scope:Eventual(function(use)
    repeat await(state) until peek(state) == "foo"
end)

Specific API surface TBD.

@dphblox dphblox added enhancement New feature or request not ready - evaluating Currently gauging feedback labels Jul 15, 2024
@bytejon
Copy link

bytejon commented Dec 5, 2024

Can the await function be called from anywhere? For example:

local eventual = Eventual(function(use)
 -- some processing that yields
end)

Computed(function(use)
 local value = await(eventual)
 -- is this allowed?
end)

If the above is allowed, then Computed states would essentially hold the same behavior as Eventuals in the sense they can be "pending". Might it be worth implementing yield support for Computed states generally? A side effect of this would be both peek and use potentially yielding if a Computed state is still "pending".

If the above is not allowed, would it make sense to throw an error claiming you cannot yield in the current context?

@dphfox
Copy link
Owner

dphfox commented Dec 9, 2024

Yielding rules in Computed likely wouldn't change here. It'll be the same as any other yielding code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request not ready - evaluating Currently gauging feedback
Projects
None yet
Development

No branches or pull requests

3 participants