Calling a new transition from inside a lifecycle method
Author: reubenabCreated Nov 8, 2017Updated Jan 21, 2021
If I want to decide between two transitions on entering a state, I am unable to call a transition from inside any lifecycle event. Say I have a very simple FSM with 3 states: A, B, and C. There is a transition A->B called step1() and another transition B->C called step2(). Say I only want to print `hello` when we get to B then call step2(). How would this be achieved? If I write an `onEnterB` or `onAfterStep1` function, I get an error saying that a new transition cannot be called while the old one is still in effect.
Source: jakesgordon/javascript-state-machine