It seems to me that you can fire an action in one of the following ways:
Explicitly
{
...
states: {
foo: {
on: {
BAR: {
actions: "performSomeAction",
target: "bar",
},
},
},
bar: {},
},
...
}
Implicitly with "entry"
{
...
states: {
foo: {
on: {
BAR: "bar",
}
},
bar: {
entry: "performSomeAction",
},
},
...
}
In what circumstances would you choose one over the other?
David Kourshid (creator of xstate) answered this on Spectrum:
They mean different things.
- Transition actions mean "execute this action only on this transition"
- Entry/exit actions mean "execute this action on any transition that enters/exits this state"