This way I can better handle if I want to cancel a transition based on the source or destination.
fsm.on(MyState.Red, (from: MyState) => {
if (from === MyState.Green) {
console.log("Transitioned from green to red");
}
});
fsm.onEnter(MyState.Red, (from: MyState) => {
if (from === MyState.Green) {
console.log("Transitioning from green to red");
}
});
fsm.onExit(MyState.Red, (to: MyState) => {
if (to === MyState.Green) {
console.log("Transitioning from red to green");
}
});
This way I can better handle if I want to cancel a transition based on the source or destination.