createLiteMachine()
createLiteMachine<
S,E>(definition,initial):object
createLiteMachine<
S,E,C>(definition,initial,initialContext):object
Creates a lightweight finite state machine (no trySend, no @zygos/option dependency).
Type Parametersβ
S: S extends stringβ
Union of state names
E: E extends stringβ
Union of event names
C: Cβ
Context type
Parametersβ
Overload 1:
definition: MachineDefinition<S, E, undefined>β
The state/transition map
initial: Sβ
The initial state
Overload 2:
definition: MachineDefinition<S, E, C>β
The state/transition map
initial: Sβ
The initial state
initialContext: Cβ
The initial context value
Returns: objectβ
A machine with current, send, matches, onTransition, reset
current(): () => Sβ
Returns: Sβ
send(): (event) => Sβ
event:
E
Returns:S
matches(): (state) => booleanβ
state:
S
Returns:boolean
onTransition(): (listener) => () => voidβ
listener:
TransitionListener<S, E>
Returns:> (): void
Returns: voidβ
reset(): () => voidβ
Returns: voidβ
Sinceβ
2.5.0