-
Notifications
You must be signed in to change notification settings - Fork 4
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
Usage with async/interpreter #1
Comments
Great insights - it would be nice to use DE with an interpreter to ensure that actions get executed. I'm thinking it might be simpler than waiting for a promise, though. Currently, the So what might make more sense is to have some sort of synchronous interpreter that both returns the next state and actions. This doesn't need to be as complex as the current interpreter, since it's just a matter of doing two things:
So it can look like this: function execTransition(machine, state, event) {
const nextState = machine.transition(state, event);
nextState.actions.forEach(action => {
// execute each action
});
return nextState;
} I'll think about this more. It's definitely an important use-case for serverless workflows. |
Thanks for the response! My understanding then is:
For a concrete example using the "invoking promises" code (below). We want to:
It makes sense to me to "wait" in this case (OPTION B) as long as the invoked services are guaranteed to resolve, however it seems a little questionable.
|
Ah, so you basically want something like |
Yeah I think so! But very new to xstate so just kind of feeling out how this would work. |
Hey @davidkpiano,
New to this library (xstate) and relatively new to Durable Entities (but big fan of both!). Wondering the recommended way of running an interpreter with Durable Entities that has some async actions. Specifically:
This question is related to this issue. As I currently understand there are 2 options:
Not sure how/if option #1 would work, however option #2 "works" at least with this simple case (shown below). Just wondering if there is a better/advised pattern for this?
To paste into xstate viz (slightly modified to add async invoke + back):
The text was updated successfully, but these errors were encountered: