R
C

AsyncStateMachine

v0.0.8tested

Async finite state machine with support for async guards, actions, and hooks

Signature

ts
class AsyncStateMachine<States extends string = string, Events extends string = string, Context = undefined> extends BaseStateMachine<States, Events, Context, AsyncStateNodeConfig<Context>>

Type Parameters

Statesextends string= string
Eventsextends string= string
Context= undefined

Methods

send

Send an event to the machine, awaiting async guards, actions, and hooks

ts
async send(event: Events): Promise<States>
ParameterTypeDescription
eventEventsEvent name
ReturnsPromise<States>The current state after processing the event
can

Check if an event can trigger a transition, awaiting async guards

ts
async can(event: Events): Promise<boolean>
ParameterTypeDescription
eventEventsEvent to check
ReturnsPromise<boolean>