How callbacks work in the state machine
masterCallbacks allow you to intercept transitions to validate or execute logic. They are divided into three types:
guard: Used to prevent a transition. The callback function must return abool. If it returnsfalse, the transition is blocked.- Use
toto trigger when moving to a specific state.
- Use
before: Executed before a transition occurs.- Use
fromto trigger when leaving a specific state.
- Use
after: Executed after a transition is applied.- Use
onto trigger for a specific transition name. - Use
toto trigger when entering a specific state.
- Use
Callbacks can be defined as anonymous functions or as an array ['object', 'methodName'] to call a method on the domain object.