Options
All
  • Public
  • Public/Protected
  • All
Menu

Class State<TContext, TEvent, TStateSchema, TTypestate>

Type Parameters

Hierarchy

  • State

Index

Constructors

  • new State<TContext, TEvent, TStateSchema, TTypestate>(config: StateConfig<TContext, TEvent>): State<TContext, TEvent, TStateSchema, TTypestate>
  • Creates a new State instance.

    Type Parameters

    Parameters

    Returns State<TContext, TEvent, TStateSchema, TTypestate>

Properties

_event: Event<TEvent>
_sessionid: null | string
actions: ActionObject<TContext, TEvent>[]
activities: ActivityMap
changed: undefined | boolean

Indicates whether the state has changed from the previous state. A state is considered "changed" if:

  • Its value is not equal to its previous value, or:
  • It has any new actions (side-effects) to execute.

An initial state (with no history) will return undefined.

children: Record<string, ActorRef<any, any>>

An object mapping actor IDs to spawned actors/invoked services.

configuration: StateNode<TContext, any, TEvent, { context: TContext; value: any }>[]

The enabled state nodes representative of the state value.

context: TContext
done: undefined | boolean

Indicates whether the state is a final state.

event: TEvent
events: TEvent[]
history?: State<TContext, TEvent, TStateSchema, TTypestate>
historyValue?: HistoryValue
meta: any
nextEvents: string[]

The next events that will cause a transition from the current state.

transitions: TransitionDefinition<TContext, TEvent>[]

The transition definitions that resulted in this state.

value: StateValue

Methods

  • matches<TSV>(parentStateValue: TSV): this is State<(TTypestate extends { value: TSV } ? TTypestate : never)["context"], TEvent, TStateSchema, TTypestate> & { value: TSV }
  • Whether the current state value is a subset of the given parent state value.

    Type Parameters

    Parameters

    • parentStateValue: TSV

    Returns this is State<(TTypestate extends { value: TSV } ? TTypestate : never)["context"], TEvent, TStateSchema, TTypestate> & { value: TSV }

  • toJSON(): Pick<State<TContext, TEvent, TStateSchema, TTypestate>, "actions" | "activities" | "history" | "meta" | "value" | "context" | "historyValue" | "events" | "event" | "_event" | "_sessionid" | "changed" | "done" | "nextEvents" | "children" | "toStrings" | "toJSON" | "matches">
  • Returns Pick<State<TContext, TEvent, TStateSchema, TTypestate>, "actions" | "activities" | "history" | "meta" | "value" | "context" | "historyValue" | "events" | "event" | "_event" | "_sessionid" | "changed" | "done" | "nextEvents" | "children" | "toStrings" | "toJSON" | "matches">

  • toStrings(stateValue?: string | StateValueMap, delimiter?: string): string[]
  • Returns an array of all the string leaf state node paths.

    Parameters

    • Optional stateValue: string | StateValueMap
    • Optional delimiter: string

      The character(s) that separate each subpath in the string state node path.

    Returns string[]

  • create<TC, TE>(config: StateConfig<TC, TE>): State<TC, TE, any, { context: TC; value: any }>
  • Creates a new State instance for the given config.

    Type Parameters

    Parameters

    Returns State<TC, TE, any, { context: TC; value: any }>

  • from<TC, TE>(stateValue: string | StateValueMap | State<TC, TE, any, { context: TC; value: any }>, context?: TC): State<TC, TE, any, { context: TC; value: any }>
  • Creates a new State instance for the given stateValue and context.

    Type Parameters

    Parameters

    • stateValue: string | StateValueMap | State<TC, TE, any, { context: TC; value: any }>
    • Optional context: TC

    Returns State<TC, TE, any, { context: TC; value: any }>

  • inert<TC, TE>(stateValue: string | StateValueMap | State<TC, TE, any, { context: TC; value: any }>, context: TC): State<TC, TE, any, { context: TC; value: any }>
  • Creates a new State instance for the given stateValue and context with no actions (side-effects).

    Type Parameters

    Parameters

    • stateValue: string | StateValueMap | State<TC, TE, any, { context: TC; value: any }>
    • context: TC

    Returns State<TC, TE, any, { context: TC; value: any }>

Generated using TypeDoc