Skip to main content
Module

x/xstate/src/StateNode.ts>StateNode

Actor-based state management & orchestration for complex app logic.
Latest
class StateNode
import { StateNode } from "https://deno.land/x/xstate@xstate%405.12.0/src/StateNode.ts";

Constructors

new
StateNode(config: StateNodeConfig<TContext, TEvent, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO>, options: StateNodeOptions<TContext, TEvent>)

Type Parameters

optional
TContext extends MachineContext = MachineContext
optional
TEvent extends EventObject = EventObject

Properties

optional
always: Array<TransitionDefinition<TContext, TEvent>>
readonly
definition: StateNodeDefinition<TContext, TEvent>

The well-structured state node definition.

optional
description: string
entry: UnknownAction[]

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

readonly
events: Array<EventDescriptor<TEvent>>

All the event types accepted by this state node and its descendants.

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

history: false | "shallow" | "deep"

The type of history on this state node. Can be:

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

The unique ID of the state node.

The logic invoked as actors by this state node.

key: string

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

machine: StateMachine<TContext, TEvent, any, any, any, any, any, any, any, any, any, any, any>

The root machine node.

optional
meta: any

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

The mapping of events to transitions.

order: number

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

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

readonly
ownEvents: Array<EventDescriptor<TEvent>>

All the events that have transitions directly from this state node.

Excludes any inert events.

optional
parent: StateNode<TContext, TEvent>

The parent state node.

path: string[]

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

The child state nodes.

tags: string[]
transitions: Map<string, TransitionDefinition<TContext, TEvent>[]>
type:
| "atomic"
| "compound"
| "parallel"
| "final"
| "history"

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

Methods

next(snapshot: MachineSnapshot<TContext, TEvent, any, any, any, any, any>, event: TEvent): TransitionDefinition<TContext, TEvent>[] | undefined