Debugging your FSM
Last updated
Was this helpful?
Last updated
Was this helpful?
FSM2 provides a number of tools to help debug your FSM.
Firstly we strongly recommend that you only use the static transitions (i.e. don't use onDynamic). As yet we have found no use cases where onDynamic is needed and it makes debugging your FSM much harder.
The first thing you should ALWAYS check is that your FSM is consistent.
You can do this by calling ().
You should create a unit test that tests your statemachine.
If you have followed our recommendation to not use 'onDynamic' then you can create a visualisation of your FSM.
We are not big fans of humongous state machines. Rather we recommend that you create a statemachine for each part of your code.
You might have an FSM for each screen or particular db updates but avoid the temptation to model your entire app as a single statemachine. This will never end well.
The statemachine allows you to hook every transition by calling 'onTransition'.
The above code prints the eventType, fromState, and toState for every transition.
We provide a number of helper functions that make it easier to unit test your statemachine.
StateMachine.waitUntilQuiescent
StateMachine.isInState
StateMachine.stateOfMind
See details on for details on viewing the .gv file.