R
C

StateMachine

v0.0.8tested

Simple, performant, and type-safe finite state machine

Signature

ts
class StateMachine<States extends string = string, Events extends string = string, Context = undefined> extends BaseStateMachine<States, Events, Context, SyncStateNodeConfig<Context>>

Type Parameters

Statesextends string= string
Eventsextends string= string
Context= undefined

Methods

send

Send an event to the machine, potentially causing a state transition

ts
send(event: Events): States
ParameterTypeDescription
eventEventsEvent name
ReturnsStatesThe current state after processing the event
can

Check if an event can trigger a transition from the current state

ts
can(event: Events): boolean
ParameterTypeDescription
eventEventsEvent to check
Returnsboolean