Clones machine state
Drives a state machine.
Returns state transitions based on a list of strings. The last string is the terminal state. A -> B -> C -> D
Returns a machine description based on a list of strings. Machine can go back and forth between states: A <-> B <-> C <-> D
Initialises a state machine
const desc = {
pants: ['shoes','socks'],
socks: ['shoes', 'pants'],
shoes: 'shirt',
shirt: null
Returns true if MachineState sm
is in its final state.
Returns true if toState
is a valid transition from current state of sm
Returns a list of possible state names for sm
, or
an empty list if no transitions are possible.
Returns a list of possible state targets for sm
, or
an empty list if no transitions are possible.
Attempts to transition to a new state. Either a new
MachineState
is returned reflecting the change, or
an exception is thrown.
A state machine that fires events when state changes.
Encapsulation of a 'running' machine description and state.
List of possible states
Possible state transitions, or null if final state.
Transition result
Maps state to allowable next states
Functions for creating and driving a state machine
See StateMachine.init to get started.