Skip to content

Advice on getting valid transition targets for node #1386

Answered by davidkpiano
mattpocock asked this question in General
Discussion options

You must be logged in to vote

Do you mean all the targets of all the transitions from a state node?

function getAllTransitionTargets(stateNode) {
  return flatten(stateNode.transitions.map(t => {
    return t.target || [];
  }));
}

That should do it. You can dedupe using Set() and recursively get all the transition targets of the sibling nodes themselves (Object.values(stateNode.states)).

This is after the machine does the "processing" of the config object.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@Andarist
Comment options

@mattpocock
Comment options

@Andarist
Comment options

@davidkpiano
Comment options

@mattpocock
Comment options

Answer selected by mattpocock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants