Class-based
ixfx’s StateMachine.WithEvents which wraps the functional implementation described above and also provides events for listening for event changes.
The same format is used to define possible transitions. Now there’s an mutable object, so const
can be used:
Change the state by name:
In some cases, you might want to ask the machine to transition to its next possible state, regardless of its current state. If multiple states are possible, it will use the first one.
Reset the machine back to its initial state with reset . This is the only way to continue after reaching the final state.
Check status
The change
event is fired whenever state changes, and stop
when the machine reaches a final state.