Skip to content

How can we get next possible states? #2175

Answered by davidkpiano
haocheng6 asked this question in Q&A
Discussion options

You must be logged in to vote

You can get the next state in a running service via:

// Pure method that does not update the state
service.nextState(event); // returns State

So you can iterate through events:

currentState.nextEvents.map(event => {
  return service.nextState(event); // and/or add some payload
});

Another related question is how can we get next possible events/states in N steps.

Using machine.transition(nextState, event) as normal (recursively for N steps).

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@linonetwo
Comment options

Answer selected by haocheng6
Comment options

You must be logged in to vote
1 reply
@linonetwo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants