Skip to content

[Feature Request] Inherit actions from parent state, or global actions #1360

Answered by davidkpiano
lins05 asked this question in General
Discussion options

You must be logged in to vote

It's not supported in XState because it's not supported in SCXML. There is an idea explored by Harel in his original paper called "clustering" which addresses this, but that idea was scrapped because of its complexity/ambiguity.

Anyway, there's a couple of ways to solve this. You can be more explicit and have two types of events; for example:

  • E1 can be for executing A1
  • E11 can be for transitioning between states

So if you think of the logic in plain terms, you can phrase it this way:

Whenever E1 happens, execute A1 and trigger a transition between the states

That second part can be the responsibility of that E11 event. A machine can send itself events, so:

const A1 = () => console.log('…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@davidkpiano
Comment options

@Andarist
Comment options

Answer selected by lins05
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants