Options
All
  • Public
  • Public/Protected
  • All
Menu

xstate

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

Action

Action: ActionType | ActionObject<TContext> | ActionFunction<TContext>

ActionFunctionMap

ActionFunctionMap: Record<string, ActionObject<TContext> | ActionFunction<TContext>>

ActionType

ActionType: string

Activity

Activity: string | ActivityDefinition<TContext>

ActivityConfig

ActivityConfig: function

Type declaration

Assigner

Assigner: function

Type declaration

    • (extState: TContext, event: TEvent): Partial<TContext>
    • Parameters

      • extState: TContext
      • event: TEvent

      Returns Partial<TContext>

BuiltInEvent

BuiltInEvent: object | RaisedEvent<TEvent> | object | ErrorExecutionEvent

Condition

Condition: string | ConditionPredicate<TContext, TEvent>

ConditionPredicate

ConditionPredicate: function

Type declaration

    • (context: TContext, event: TEvent, microstepState: StateValue): boolean
    • Parameters

      • context: TContext
      • event: TEvent
      • microstepState: StateValue

      Returns boolean

ConditionalTransitionConfig

ConditionalTransitionConfig: Array<TransitionConfig<TContext, TEvent>>

DefaultContext

DefaultContext: Record<string, any> | undefined

DelayedTransitions

DelayedTransitions: Record<string | number, string | TransitionConfig<TContext, TEvent> | Array<TransitionConfig<TContext, TEvent>>> | Array<TransitionConfig<TContext, TEvent> & object>

DisposeActivityFunction

DisposeActivityFunction: function

Type declaration

    • (): void
    • Returns void

DoneEvent

DoneEvent: DoneEventObject & string

Event

Event: TEvent["type"] | TEvent

The specified string event types or the specified event objects.

EventType

EventType: string

InvokeConfig

InvokeConfig: object | Machine<any, any, any>

InvokeCreator

InvokeCreator: function

Type declaration

    • (ctx: TContext, event: EventObject): Promise<TFinalContext>
    • Parameters

      Returns Promise<TFinalContext>

InvokesConfig

InvokesConfig: InvokeConfig<TContext, TEvent> | Array<InvokeConfig<TContext, TEvent>>

Mapper

Mapper: function

Type declaration

    • (extState: TContext, event: TEvent): any
    • Parameters

      • extState: TContext
      • event: TEvent

      Returns any

MetaObject

MetaObject: Record<string, any>

OmniEvent

OmniEvent: TEvent["type"] | Raise | NullEvent | Init | ErrorExecution | OmniEventObject<TEvent>

Represents the specified event types or the full event objects, as well as the built in event types and/or objects.

OmniEventObject

OmniEventObject: TEvent | BuiltInEvent<TEvent>

Represents the specified events and the built-in internal events.

PropertyAssigner

PropertyAssigner: Partial<object>

PropertyMapper

PropertyMapper: Partial<object>

ServiceConfig

ServiceConfig: string | StateNode | StateNodeDefinition<any, any, any>

SimpleOrCompoundStateNodeConfig

SimpleOrCompoundStateNodeConfig: AtomicStateNodeConfig<TContext, TEvent> | CompoundStateNodeConfig<TContext, TStateSchema, TEvent>

SingleOrArray

SingleOrArray: T[] | T

StateKey

StateKey: string | State<any>

StateNodesConfig

StateNodesConfig: object

Type declaration

StateTypes

StateTypes: "atomic" | "compound" | "parallel" | "final" | "history"

StateValue

StateValue: string | StateValueMap

The string or object representing the state value relative to the parent state node.

  • For a child atomic state node, this is a string, e.g., "pending".
  • For complex state nodes, this is an object, e.g., { success: "someChildState" }.

StatesConfig

StatesConfig: object

Type declaration

StatesDefinition

StatesDefinition: object

Type declaration

Transition

Transition: string | TransitionConfig<TContext, TEvent> | ConditionalTransitionConfig<TContext, TEvent>

TransitionsConfig

TransitionsConfig: object

Type declaration

TransitionsDefinition

TransitionsDefinition: object

Type declaration

Variables

Const EMPTY_ACTIVITY_MAP

EMPTY_ACTIVITY_MAP: ActivityMap

Const EMPTY_OBJECT

EMPTY_OBJECT: object

Type declaration

Const IS_PRODUCTION

IS_PRODUCTION: boolean = typeof process !== 'undefined' ? process.env.NODE_ENV === 'production' : true

Const NULL_EVENT

NULL_EVENT: "" = ""

Const STATE_DELIMITER

STATE_DELIMITER: "." = "."

Const STATE_IDENTIFIER

STATE_IDENTIFIER: "#" = "#"

Const TARGETLESS_KEY

TARGETLESS_KEY: "" = ""

Const after

  • after(delay: number, id?: undefined | string): string
  • Returns an event type that represents an implicit event that is sent after the specified delay.

    Parameters

    • delay: number

      The delay in milliseconds

    • Optional id: undefined | string

      The state node ID where this event is handled

    Returns string

Const doneState

doneState: DoneState = ActionTypes.DoneState

Const errorExecution

errorExecution: ErrorExecution = ActionTypes.ErrorExecution

Const init

init: Init = ActionTypes.Init

Const invoke

  • Invokes (spawns) a child service, as a separate interpreted machine.

    Type parameters

    Parameters

    • invokeConfig: string | InvokeConfig<TContext, TEvent> | Machine<any, any, any>

      The string service to invoke, or a config object:

      • src - The source (URL) of the machine definition to invoke
      • forward - Whether events sent to this machine are sent (forwarded) to the invoked machine.
    • Optional options: Partial<InvokeDefinition<TContext, TEvent>>

    Returns InvokeDefinition<TContext, TEvent>

Const log

  • log<TContext, TEvent>(expr?: function, label?: undefined | string): object
  • Type parameters

    Parameters

    • Default value expr: function = (context, event) => ({context,event})

      The expression function to evaluate which will be logged. Takes in 2 arguments:

      • ctx - the current state context
      • event - the event that caused this action to be executed.
        • (ctx: TContext, event: TEvent): any
        • Parameters

          • ctx: TContext
          • event: TEvent

          Returns any

    • Optional label: undefined | string

      The label to give to the logged expression.

    Returns object

    • expr: function
        • (ctx: TContext, event: TEvent): any
        • Parameters

          • ctx: TContext
          • event: TEvent

          Returns any

    • label: undefined | string
    • type: ActionTypes

Const nullEvent

nullEvent: NullEvent = ActionTypes.NullEvent

Const raise

  • raise<TContext, TEvent>(event: Event<TEvent>): RaiseEvent<TContext, TEvent>
  • Raises an event. This places the event in the internal event queue, so that the event is immediately consumed by the machine in the current step.

    Type parameters

    Parameters

    Returns RaiseEvent<TContext, TEvent>

Const send

  • Sends an event. This returns an action that will be read by an interpreter to send the event in the next step, after the current step is finished executing.

    Type parameters

    Parameters

    • event: Event<TEvent>

      The event to send.

    • Optional options: SendActionOptions

      Options to pass into the send event:

      • id - The unique send event identifier (used with cancel()).
      • delay - The number of milliseconds to delay the sending of the event.
      • target - The target of this event (by default, the machine the event was sent from).

    Returns SendAction<TContext, TEvent>

Const start

Const stop

Functions

Const assign

Const cancel

  • Cancels an in-flight send(...) action. A canceled sent action will not be executed, nor will its event be sent, unless it has already been sent (e.g., if cancel(...) is called after the send(...) action's delay).

    Parameters

    • sendId: string | number

      The id of the send(...) action to cancel.

    Returns CancelAction

Const createDefaultOptions

done

  • Returns an event that represents that a final state node has been reached in the parent state node.

    Parameters

    • id: string

      The final state node's parent state node id

    • Optional data: any

      The data to pass into the event

    Returns DoneEventObject

doneInvoke

  • doneInvoke(id: string, data?: any): DoneEvent
  • Returns an event that represents that an invoked service has terminated.

    An invoked service is terminated when it has reached a top-level final state node, but not when it is canceled.

    Parameters

    • id: string

      The final state node ID

    • Optional data: any

      The data to pass into the event

    Returns DoneEvent

error

flatten

  • flatten<T>(array: T[][]): T[]
  • Type parameters

    • T

    Parameters

    • array: T[][]

    Returns T[]

getActionFunction

getActionType

getEventType

  • getEventType<TEvent>(event: Event<TEvent>): TEvent["type"]

isActionObject

  • isActionObject<TContext>(action: Action<TContext>): boolean
  • Type parameters

    • TContext

    Parameters

    Returns boolean

isState

  • isState(state: any | string): boolean
  • Parameters

    • state: any | string

    Returns boolean

Const isStateId

  • isStateId(str: string): boolean

keys

  • keys<T>(value: T): Array<keyof T & string>
  • Type parameters

    • T: any

    Parameters

    • value: T

    Returns Array<keyof T & string>

mapContext

  • mapContext<TContext, TEvent>(mapper: Mapper<TContext, TEvent> | PropertyMapper<TContext, TEvent>, context: TContext, event: TEvent): any

mapFilterValues

  • mapFilterValues<T, P>(collection: object, iteratee: function, predicate: function): object
  • Type parameters

    • T

    • P

    Parameters

    • collection: object
      • [key: string]: T
    • iteratee: function
        • (item: T, key: string, collection: object): P
        • Parameters

          • item: T
          • key: string
          • collection: object
            • [key: string]: T

          Returns P

    • predicate: function
        • (item: T): boolean
        • Parameters

          • item: T

          Returns boolean

    Returns object

    • [key: string]: P

mapState

  • mapState(stateMap: object, stateId: string): any
  • Parameters

    • stateMap: object
      • [stateId: string]: any
    • stateId: string

    Returns any

mapValues

  • mapValues<T, P>(collection: object, iteratee: function): object
  • Type parameters

    • T

    • P

    Parameters

    • collection: object
      • [key: string]: T
    • iteratee: function
        • (item: T, key: string, collection: object, i: number): P
        • Parameters

          • item: T
          • key: string
          • collection: object
            • [key: string]: T
          • i: number

          Returns P

    Returns object

    • [key: string]: P

matchesState

nestedPath

  • nestedPath<T>(props: string[], accessorProp: keyof T): function
  • Retrieves a value at the given path via the nested accessor prop.

    Type parameters

    • T: Record<string, any>

    Parameters

    • props: string[]

      The deep path to the prop of the desired value

    • accessorProp: keyof T

    Returns function

      • (object: T): T
      • Parameters

        • object: T

        Returns T

Const path

  • path<T>(props: string[]): any
  • Retrieves a value at the given path.

    Type parameters

    • T: Record<string, any>

    Parameters

    • props: string[]

      The deep path to the prop of the desired value

    Returns any

pathToStateValue

  • pathToStateValue(statePath: string[]): StateValue

Const pathsToStateValue

  • pathsToStateValue(paths: string[][]): StateValue

sendParent

  • Sends an event to this machine's parent machine.

    Type parameters

    Parameters

    • event: Event<TEvent>

      The event to send to the parent machine.

    • Optional options: SendActionOptions

      Options to pass into the send event.

    Returns SendAction<TContext, TEvent>

stateValuesEqual

toActionObject

Const toActionObjects

toActivityDefinition

toArray

  • toArray<T>(value: T[] | T | undefined): T[]
  • Type parameters

    • T

    Parameters

    • value: T[] | T | undefined

    Returns T[]

toEventObject

  • toEventObject<TEvent>(event: Event<TEvent>): TEvent

toStatePath

  • toStatePath(stateId: string | string[], delimiter: string): string[]
  • Parameters

    • stateId: string | string[]
    • delimiter: string

    Returns string[]

Const toStatePaths

  • toStatePaths(stateValue: StateValue | undefined): string[][]

toStateValue

Object literals

Const actions

actions: object

after

after: after

assign

assign: assign

cancel

cancel: cancel

done

done: done

invoke

invoke: invoke

log

log: log

raise

raise: raise

send

send: send

sendParent

sendParent: sendParent

start

start: start

stop

stop: stop

Const defaultStateTreeOptions

defaultStateTreeOptions: object

resolved

resolved: boolean = false

Generated using TypeDoc