Options
All
  • Public
  • Public/Protected
  • All
Menu

Class StateNode<TContext, TStateSchema, TEvent>

Type parameters

Hierarchy

Index

Constructors

constructor

Properties

activities

activities: Array<ActivityDefinition<TContext>>

The activities to be started upon entering the state node, and stopped upon exiting the state node.

Optional context

context: Readonly<TContext>

The initial extended state

Optional data

data: Mapper<TContext, TEvent> | PropertyMapper<TContext, TEvent>

The data sent with the "done.state.id" event if this is a final state node.

delimiter

delimiter: string

The string delimiter for serializing the path to a string. The default is "."

history

history: false | "shallow" | "deep"

The type of history exhibited. Can be:

  • 'shallow' - recalls only top-level historical state value
  • 'deep' - recalls historical state value at all levels

id

id: string

The unique ID of the state node.

Optional initial

initial: keyof TStateSchema["states"]

The initial state node key.

invoke

invoke: Array<InvokeDefinition<TContext, TEvent>>

The services invoked by this state node.

key

key: string

The relative key of the state node, which represents its location in the overall state value.

machine

machine: StateNode<TContext>

The root machine node.

Optional meta

meta: undefined | TStateSchema extends { meta: infer D; } ? D : any

The meta data associated with this state node, which will be returned in State instances.

onEntry

onEntry: Array<ActionObject<TContext>>

The action(s) to be executed upon entering the state node.

onExit

onExit: Array<ActionObject<TContext>>

The action(s) to be executed upon exiting the state node.

options

options: Readonly<MachineOptions<TContext, TEvent>>

order

order: number

The order this state node appears. Corresponds to the implicit SCXML document order.

parallel

parallel: boolean

(DEPRECATED) Whether the state node is a parallel state node.

Use type: 'parallel' instead.

Optional parent

parent: StateNode<TContext>

The parent state node.

path

path: string[]

The string path from the root machine node to this node.

states

states: StateNodesConfig<TContext, TStateSchema, TEvent>

The child state nodes.

strict

strict: boolean

transient

transient: boolean

Whether the state node is "transient". A state node is considered transient if it has an immediate transition from a "null event" (empty string), taken upon entering the state node.

type

The type of this state node:

  • 'atomic' - no child state nodes
  • 'compound' - nested child state nodes (XOR)
  • 'parallel' - orthogonal nested child state nodes (AND)
  • 'history' - history state node
  • 'final' - final state node

Accessors

after

config

definition

delays

events

  • get events(): Array<TEvent["type"]>
  • All the event types accepted by this state node and its descendants.

    Returns Array<TEvent["type"]>

initialState

  • get initialState(): State<TContext, TEvent>
  • The initial State instance, which includes all actions to be executed from entering the initial state.

    Returns State<TContext, TEvent>

initialStateNodes

  • get initialStateNodes(): Array<StateNode<TContext>>

on

ownEvents

  • get ownEvents(): Array<TEvent["type"]>
  • All the events that have transitions directly from this state node.

    Excludes any inert events.

    Returns Array<TEvent["type"]>

stateIds

  • get stateIds(): string[]
  • All the state node IDs of this state node and its descendant state nodes.

    Returns string[]

target

  • The target state value of the history state node, if it exists. This represents the default state value to transition to if no history value exists yet.

    Returns StateValue | undefined

transitions

Methods

getFromRelativePath

  • Retrieves state nodes from a relative path to this state node.

    Parameters

    • relativePath: string[]

      The relative path from this state node

    • Optional historyValue: HistoryValue

    Returns Array<StateNode<TContext>>

getInitialState

  • getInitialState(stateValue: StateValue, context?: TContext): State<TContext, TEvent>

getRelativeStateNodes

  • getRelativeStateNodes(relativeStateId: string | string[], historyValue?: HistoryValue, resolve?: boolean): Array<StateNode<TContext>>
  • Returns the leaf nodes from a state path relative to this state node.

    Parameters

    • relativeStateId: string | string[]

      The relative state path to retrieve the state nodes

    • Optional historyValue: HistoryValue
    • Default value resolve: boolean = true

      Whether state nodes should resolve to initial child state nodes

    Returns Array<StateNode<TContext>>

getStateNode

  • getStateNode(stateKey: string): StateNode<TContext>
  • Returns the child state node from its relative stateKey, or throws.

    Parameters

    • stateKey: string

    Returns StateNode<TContext>

getStateNodeById

  • getStateNodeById(stateId: string): StateNode<TContext>
  • Returns the state node with the given stateId, or throws.

    Parameters

    • stateId: string

      The state ID. The prefix "#" is removed.

    Returns StateNode<TContext>

getStateNodeByPath

  • getStateNodeByPath(statePath: string | string[]): StateNode<TContext>
  • Returns the relative state node from the given statePath, or throws.

    Parameters

    • statePath: string | string[]

      The string or string array relative path to the state node.

    Returns StateNode<TContext>

getStateNodes

  • Returns the state nodes represented by the current state value.

    Parameters

    • state: StateValue | State<TContext, TEvent>

      The state value or State instance

    Returns Array<StateNode<TContext>>

getStates

handles

  • handles(event: Event<TEvent>): boolean
  • Whether this state node explicitly handles the given event.

    Parameters

    • event: Event<TEvent>

      The event in question

    Returns boolean

resolve

  • Resolves a partial state value with its full representation in this machine.

    Parameters

    • stateValue: StateValue

      The partial state value to resolve.

    Returns StateValue

transition

  • Determines the next state given the current state and sent event.

    Parameters

    • state: StateValue | State<TContext, TEvent>

      The current State instance or state value

    • event: OmniEvent<TEvent>

      The event that was sent at the current state

    • Optional context: TContext

      The current context (extended state) of the current state

    Returns State<TContext, TEvent>

withConfig

  • Clones this state machine with custom options and context.

    Parameters

    • options: MachineOptions<TContext, TEvent>

      Options (actions, guards, activities, services) to recursively merge with the existing options.

    • Optional context: TContext

      Custom context (will override predefined context)

    Returns StateNode<TContext, TStateSchema, TEvent>

withContext

  • withContext(context: TContext): StateNode<TContext, TStateSchema, TEvent>
  • Clones this state machine with custom context.

    Parameters

    • context: TContext

      Custom context (will override predefined context, not recursive)

    Returns StateNode<TContext, TStateSchema, TEvent>

Generated using TypeDoc