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

block state updates while command is in flight #97

Open
rkuhn opened this issue Feb 28, 2024 · 0 comments
Open

block state updates while command is in flight #97

rkuhn opened this issue Feb 28, 2024 · 0 comments

Comments

@rkuhn
Copy link
Member

rkuhn commented Feb 28, 2024

Currently the user needs to defend against getting an unrelated state update originating from a network event immediately after invoking a command:

let thingDone = false
for await (const state of machine) {
  if (state.is(SomeState) && !thingDonw) {
    state.cast().commands()?.doTheThing()
    thingDone = true
  }
}

It would be nicer and more intuitive if the next loop iteration was guaranteed to contain the information that was published via the doTheThing action (which usually will be reflected in transitioning to a new state, but might also just add something to the current state).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant