Create a state machine with initial state, description and options
Machine description
Options for machine (defaults to {debug:false}
)
Returns timestamp when state was last changed.
See also elapsed
Returns milliseconds elapsed since last state change.
See also changedAt
Returns true if state machine is in its final state
Gets or sets state. Throws an error if an invalid transition is attempted.
Use isValid()
to check validity without changing.
If newState
is the same as current state, the request is ignored silently.
Return a list of all defined states
Return a list of possible states from current state.
If list is empty, no states are possible. Otherwise lists possible states, including 'null' for terminal
Adds event listener.
Events
Event name
Event handler
Protected
fireFire event
Type of event
Arguments for event
Returns true if newState
is valid transition from current state.
Use validateTransition if you want an explanation for the false results.
Remove event listener
Throws if it's not valid to transition to newState
A state machine that fires events when state changes.