StateMachine <TContext, TEvent, TChildren, TActor, TAction, TGuard, TDelay, TStateValue, TTag, TInput, TOutput, TResolvedTypesMeta>
Implements
- ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, TEvent, TInput, TODO>
Index
Constructors
constructor
Type parameters
- TContext: MachineContext
- TEvent: EventObject
- TChildren: Record<string, undefined | AnyActorRef>
- TActor: ProvidedActor
- TAction: ParameterizedObject
- TGuard: ParameterizedObject
- TDelay: string
- TStateValue: StateValue
- TTag: string
- TInput
- TOutput
- TResolvedTypesMeta = ResolveTypegenMeta<TypegenDisabled, NoInfer<TEvent>, TActor, TAction, TGuard, TDelay, TTag>
Parameters
config: MachineConfig<TContext, TEvent, any, any, any, any, any, any, TOutput, any>
The raw config used to create the machine.
optionalimplementations: MachineImplementationsSimplified<TContext, TEvent, ProvidedActor, ParameterizedObject, ParameterizedObject>
Returns StateMachine<TContext, TEvent, TChildren, TActor, TAction, TGuard, TDelay, TStateValue, TTag, TInput, TOutput, TResolvedTypesMeta>
Properties
__TResolvedTypesMeta
public__xstatenode
publicconfig
The raw config used to create the machine.
publicevents
publicid
publicidMap
publicimplementations
publicroot
publicstates
publicoptionalversion
The machine's own version.
Accessors
publicdefinition
Returns StateMachineDefinition<TContext, TEvent>
Methods
publicgetInitialSnapshot
Returns the initial
State
instance, with reference toself
as anActorRef
.Parameters
actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, TEvent, AnyActorSystem>
optionalinput: TInput
Returns MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>
publicgetPersistedSnapshot
Obtains the internal state of the actor in a representation which can be be persisted. The persisted state can be restored by
restoreSnapshot
.Parameters
snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>
The current state.
optionaloptions: unknown
Returns Snapshot<unknown>
The a representation of the internal state to be persisted.
publicgetStateNodeById
Parameters
stateId: string
Returns StateNode<TContext, TEvent>
publicgetTransitionData
Parameters
snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>
event: TEvent
Returns TransitionDefinition<TContext, TEvent>[]
publicmicrostep
Determines the next state given the current
state
andevent
. Calculates a microstep.Parameters
snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>
event: TEvent
The received event
actorScope: AnyActorScope
Returns MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>[]
publicprovide
Clones this state machine with the provided implementations and merges the
context
(if provided).Parameters
implementations: { [ K in string | number | symbol ]: { [K in keyof ((IsNever<Prop<Prop<Prop<TResolvedTypesMeta, "resolved">, "missingImplementations">, "actions">> extends true ? {} : { ...; }) & { ...; })]: ((IsNever<...> extends true ? {} : { ...; }) & { ...; })[K]; } & { [K in keyof ((IsNever<Prop<Prop<Prop<TResolvedTypesMeta, "resolved">, "missingImplementations">, "actors">> extends true ? {} : { ...; }) & { ...; })]: ((IsNever<...> extends true ? {} : { ...; }) & { ...; })[K]; } & { [K in keyof ((IsNever<Prop<Prop<Prop<TResolvedTypesMeta, "resolved">, "missingImplementations">, "delays">> extends true ? {} : { ...; }) & { ...; })]: ((IsNever<...> extends true ? {} : { ...; }) & { ...; })[K]; } & { [K in keyof ((IsNever<Prop<Prop<Prop<TResolvedTypesMeta, "resolved">, "missingImplementations">, "guards">> extends true ? {} : { ...; }) & { ...; })]: ((IsNever<...> extends true ? {} : { ...; }) & { ...; })[K]; }[K] }
Options (
actions
,guards
,actors
,delays
,context
) to recursively merge with the existing options.
Returns StateMachine<TContext, TEvent, TChildren, TActor, TAction, TGuard, TDelay, TStateValue, TTag, TInput, TOutput, AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta> extends false ? MarkAllImplementationsAsProvided<TResolvedTypesMeta> : TResolvedTypesMeta>
A new
StateMachine
instance with the provided implementations.
publicresolveState
Parameters
config: { context?: TContext; error?: unknown; historyValue?: HistoryValue<TContext, TEvent>; output?: TOutput; status?: error | active | done | stopped; value: StateValue } & (Equals<TContext, MachineContext> extends false ? { context: unknown } : {})
Returns MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>
publicrestoreSnapshot
Called when Actor is created to restore the internal state of the actor given a persisted state. The persisted state can be created by
getPersistedSnapshot
.Parameters
snapshot: Snapshot<unknown>
The persisted state to restore from.
_actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, TEvent, AnyActorSystem>
The actor scope.
Returns MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>
The restored state.
publicstart
Called when the actor is started.
Parameters
snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>
The starting state.
Returns void
publictoJSON
Returns StateMachineDefinition<TContext, TEvent>
publictransition
Determines the next snapshot given the current
snapshot
and receivedevent
. Calculates a full macrostep from all microsteps.Parameters
snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>
The current snapshot
event: TEvent
The received event
actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>, TEvent, AnyActorSystem>
Returns MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TResolvedTypesMeta>
Represents logic which can be used by an actor.