Options
All
  • Public
  • Public/Protected
  • All
Menu

Class State<TContext, TEvent>

Type parameters

Hierarchy

  • State

Implements

Index

Constructors

constructor

Properties

actions

actions: Array<ActionObject<TContext>> = []

activities

activities: ActivityMap = EMPTY_ACTIVITY_MAP

context

context: TContext

events

events: TEvent[] = []

Optional history

history: State<TContext>

Optional historyValue

historyValue: HistoryValue | undefined

meta

meta: any

Optional tree

tree: StateTree

The state node tree representation of the state value.

value

value: StateValue

Accessors

changed

  • get changed(): boolean | undefined
  • 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.

    Returns boolean | undefined

nextEvents

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

    Returns EventType[]

Methods

matches

  • Whether the current state value is a subset of the given parent state value.

    Parameters

    Returns boolean

toStrings

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

    Parameters

    • Default value stateValue: StateValue = this.value
    • Default value delimiter: string = "."

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

    Returns string[]

Static create

Static from

  • Creates a new State instance for the given stateValue and context.

    Type parameters

    Parameters

    Returns State<TC, TE>

Static inert

  • Creates a new State instance for the given stateValue and context with no actions (side-effects).

    Type parameters

    Parameters

    Returns State<TC, TE>

Generated using TypeDoc