Options
All
  • Public
  • Public/Protected
  • All
Menu

xstate

Index

Namespaces

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

Action

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

Type parameters

ActionFunction

ActionFunction<TContext, TEvent>: (context: TContext, event: TEvent, meta: ActionMeta<TContext, TEvent>) => void

Type parameters

Type declaration

    • (context: TContext, event: TEvent, meta: ActionMeta<TContext, TEvent>): void
    • Parameters

      • context: TContext
      • event: TEvent
      • meta: ActionMeta<TContext, TEvent>

      Returns void

ActionFunctionMap

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

Type parameters

ActionType

ActionType: string

Actions

Actions<TContext, TEvent>: SingleOrArray<Action<TContext, TEvent>>

Type parameters

Activity

Activity<TContext, TEvent>: string | ActivityDefinition<TContext, TEvent>

Type parameters

ActivityConfig

ActivityConfig<TContext, TEvent>: (ctx: TContext, activity: ActivityDefinition<TContext, TEvent>) => DisposeActivityFunction | void

Type parameters

Type declaration

ActorRefFrom

ActorRefFrom<T>: T extends StateMachine<infer TContext, any, infer TEvent, infer TTypestate> ? SpawnedActorRef<TEvent, State<TContext, TEvent, any, TTypestate>> & { state: State<TContext, TEvent, any, TTypestate> } : never

Type parameters

AdjList

AdjList<TC, TE>: Map<StateNode<TC, any, TE>, Array<StateNode<TC, any, TE>>>

Type parameters

AnyFunction

AnyFunction: (...args: any[]) => any

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

AnyInterpreter

AnyInterpreter: Interpreter<any, any, any, any>

AnyStateNodeDefinition

AnyStateNodeDefinition: StateNodeDefinition<any, any, any>

Assigner

Assigner<TContext, TEvent>: (context: TContext, event: TEvent, meta: AssignMeta<TContext, TEvent>) => Partial<TContext>

Type parameters

Type declaration

    • (context: TContext, event: TEvent, meta: AssignMeta<TContext, TEvent>): Partial<TContext>
    • Parameters

      • context: TContext
      • event: TEvent
      • meta: AssignMeta<TContext, TEvent>

      Returns Partial<TContext>

Cast

Cast<A1, A2>: A1 extends A2 ? A1 : A2

Type parameters

  • A1: any

  • A2: any

Compute

Compute<A>: {} & unknown

Type parameters

  • A: any

Condition

Condition<TContext, TEvent>: string | ConditionPredicate<TContext, TEvent> | Guard<TContext, TEvent>

Type parameters

ConditionPredicate

ConditionPredicate<TContext, TEvent>: (context: TContext, event: TEvent, meta: GuardMeta<TContext, TEvent>) => boolean

Type parameters

Type declaration

    • (context: TContext, event: TEvent, meta: GuardMeta<TContext, TEvent>): boolean
    • Parameters

      • context: TContext
      • event: TEvent
      • meta: GuardMeta<TContext, TEvent>

      Returns boolean

ConditionalTransitionConfig

ConditionalTransitionConfig<TContext, TEvent>: Array<TransitionConfig<TContext, TEvent>>

Type parameters

Configuration

Configuration<TC, TE>: Iterable<StateNode<TC, any, TE>>

Type parameters

ContextListener

ContextListener<TContext>: (context: TContext, prevContext: TContext | undefined) => void

Type parameters

  • TContext

Type declaration

    • (context: TContext, prevContext: TContext | undefined): void
    • Parameters

      • context: TContext
      • prevContext: TContext | undefined

      Returns void

DefaultContext

DefaultContext: Record<string, any> | undefined

DefaultGuardType

DefaultGuardType: "xstate.guard"

DelayConfig

DelayConfig<TContext, TEvent>: number | DelayExpr<TContext, TEvent>

Type parameters

DelayExpr

DelayExpr<TContext, TEvent>: ExprWithMeta<TContext, TEvent, number>

Type parameters

DelayFunctionMap

DelayFunctionMap<TContext, TEvent>: Record<string, DelayConfig<TContext, TEvent>>

Type parameters

DelayedTransitions

DelayedTransitions<TContext, TEvent>: Record<string | number, string | SingleOrArray<TransitionConfig<TContext, TEvent>>> | Array<TransitionConfig<TContext, TEvent> & { delay: number | string | Expr<TContext, TEvent, number> }>

Type parameters

DisposeActivityFunction

DisposeActivityFunction: () => void

Type declaration

    • (): void
    • Returns void

DoneEvent

DoneEvent: DoneEventObject & string

Event

Event<TEvent>: TEvent["type"] | TEvent

The specified string event types or the specified event objects.

Type parameters

EventCreator

EventCreator<Self, Return>: Return extends object ? Return extends { type: any } ? "An event creator can't return an object with a type property" : Self : "An event creator must return an object"

Type parameters

EventCreators

EventCreators<Self>: {}

Type parameters

  • Self

Type declaration

EventData

EventData: Record<string, any> & { type?: undefined }

EventFromEventCreators

EventFromEventCreators<EventCreators>: {}[keyof EventCreators]

Type parameters

  • EventCreators

EventListener

EventListener<TEvent>: (event: TEvent) => void

Type parameters

Type declaration

    • (event: TEvent): void
    • Parameters

      • event: TEvent

      Returns void

EventType

EventType: string

ExcludeType

ExcludeType<A>: {}

Type parameters

  • A

Type declaration

Expr

Expr<TContext, TEvent, T>: (context: TContext, event: TEvent) => T

Type parameters

Type declaration

    • (context: TContext, event: TEvent): T
    • Parameters

      • context: TContext
      • event: TEvent

      Returns T

ExprWithMeta

ExprWithMeta<TContext, TEvent, T>: (context: TContext, event: TEvent, meta: SCXMLEventMeta<TEvent>) => T

Type parameters

Type declaration

    • Parameters

      Returns T

ExtractEvent

ExtractEvent<TEvent, TEventType>: TEvent extends { type: TEventType } ? TEvent : never

Type parameters

ExtractExtraParameters

ExtractExtraParameters<A, T>: A extends { type: T } ? ExcludeType<A> : never

Type parameters

  • A

  • T

ExtractSimple

ExtractSimple<A>: A extends any ? {} extends ExcludeType<A> ? A : never : never

Type parameters

  • A

ExtractStateValue

ExtractStateValue<TSchema>: keyof TSchema["states"]

Type parameters

FinalEventCreators

FinalEventCreators<Self>: {}

Type parameters

  • Self

Type declaration

FinalModelCreators

FinalModelCreators<Self>: { events: FinalEventCreators<Prop<Self, "events">> }

Type parameters

  • Self

Type declaration

Guard

Guard<TContext, TEvent>: GuardPredicate<TContext, TEvent> | ({} & { type: string })

Type parameters

InvokeCallback

InvokeCallback: (callback: Sender<any>, onReceive: Receiver<EventObject>) => any

Type declaration

InvokeCreator

InvokeCreator<TContext, TEvent, TFinalContext>: (context: TContext, event: TEvent, meta: InvokeMeta) => PromiseLike<TFinalContext> | StateMachine<TFinalContext, any, any> | Subscribable<any> | InvokeCallback

Returns either a Promises or a callback handler (for streams of events) given the machine's current context and event that invoked the service.

For Promises, the only events emitted to the parent will be:

  • done.invoke.<id> with the data containing the resolved payload when the promise resolves, or:
  • error.platform.<id> with the data containing the caught error, and src containing the service id.

For callback handlers, the callback will be provided, which will send events to the parent service.

param

The current machine context

param

The event that invoked the service

Type parameters

  • TContext

  • TEvent

  • TFinalContext

Type declaration

KeysWithStates

KeysWithStates<TStates>: TStates extends object ? {}[keyof TStates] : never

Type parameters

Listener

Listener: () => void

Type declaration

    • (): void
    • Returns void

LogExpr

LogExpr<TContext, TEvent>: ExprWithMeta<TContext, TEvent, any>

Type parameters

Mapper

Mapper<TContext, TEvent, TParams>: (context: TContext, event: TEvent) => TParams

Type parameters

Type declaration

    • (context: TContext, event: TEvent): TParams
    • Parameters

      • context: TContext
      • event: TEvent

      Returns TParams

MetaObject

MetaObject: Record<string, any>

ModelContextFrom

ModelContextFrom<TModel>: TModel extends Model<infer TContext, any, any> ? TContext : never

Type parameters

  • TModel: Model<any, any, any>

ModelCreators

ModelCreators<Self>: { events: EventCreators<Prop<Self, "events">> }

Type parameters

  • Self

Type declaration

ModelEventsFrom

ModelEventsFrom<TModel>: TModel extends Model<any, infer TEvent, any> ? TEvent : never

Type parameters

  • TModel: Model<any, any, any>

NeverIfEmpty

NeverIfEmpty<T>: {} extends T ? never : T

Type parameters

  • T

PartialAssigner

PartialAssigner<TContext, TEvent, TKey>: (context: TContext, event: TEvent, meta: AssignMeta<TContext, TEvent>) => TContext[TKey]

Type parameters

Type declaration

    • (context: TContext, event: TEvent, meta: AssignMeta<TContext, TEvent>): TContext[TKey]
    • Parameters

      • context: TContext
      • event: TEvent
      • meta: AssignMeta<TContext, TEvent>

      Returns TContext[TKey]

Prop

Prop<T, K>: K extends keyof T ? T[K] : never

Type parameters

  • T

  • K

PropertyAssigner

PropertyAssigner<TContext, TEvent>: {}

Type parameters

Type declaration

PropertyMapper

PropertyMapper<TContext, TEvent, TParams>: {}

Type parameters

Type declaration

Receiver

Receiver<TEvent>: (listener: (event: TEvent) => void) => void

Type parameters

Type declaration

    • (listener: (event: TEvent) => void): void
    • Parameters

      • listener: (event: TEvent) => void
          • (event: TEvent): void
          • Parameters

            • event: TEvent

            Returns void

      Returns void

SendExpr

SendExpr<TContext, TEvent, TSentEvent>: ExprWithMeta<TContext, TEvent, TSentEvent>

Type parameters

Sender

Sender<TEvent>: (event: Event<TEvent>) => void

Type parameters

Type declaration

    • (event: Event<TEvent>): void
    • Parameters

      Returns void

ServiceConfig

ServiceConfig<TContext, TEvent>: string | StateMachine<any, any, any> | InvokeCreator<TContext, TEvent>

Type parameters

ServiceListener

ServiceListener: (service: AnyInterpreter) => void

Type declaration

SimpleOrStateNodeConfig

SimpleOrStateNodeConfig<TContext, TStateSchema, TEvent>: AtomicStateNodeConfig<TContext, TEvent> | StateNodeConfig<TContext, TStateSchema, TEvent>

Type parameters

SingleOrArray

SingleOrArray<T>: T[] | T

Type parameters

  • T

Spawnable

Spawnable: StateMachine<any, any, any> | Promise<any> | InvokeCallback | Subscribable<any>

StateFrom

StateFrom<TMachine>: ReturnType<TMachine["transition"]>

Type parameters

StateKey

StateKey: string | State<any>

StateListener

StateListener<TContext, TEvent, TStateSchema, TTypestate>: (state: State<TContext, TEvent, TStateSchema, TTypestate>, event: TEvent) => void

Type parameters

Type declaration

    • (state: State<TContext, TEvent, TStateSchema, TTypestate>, event: TEvent): void
    • Parameters

      • state: State<TContext, TEvent, TStateSchema, TTypestate>
      • event: TEvent

      Returns void

StateNodesConfig

StateNodesConfig<TContext, TStateSchema, TEvent>: {}

Type parameters

Type declaration

StatePatternTuple

StatePatternTuple<T, TContext, TEvent>: []

Type parameters

StateTypes

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

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<TContext, TStateSchema, TEvent>: {}

Type parameters

Type declaration

StatesDefinition

StatesDefinition<TContext, TStateSchema, TEvent>: {}

Type parameters

Type declaration

Transition

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

Type parameters

TransitionConfigOrTarget

TransitionConfigOrTarget<TContext, TEvent>: SingleOrArray<TransitionConfigTarget<TContext, TEvent> | TransitionConfig<TContext, TEvent>>

Type parameters

TransitionConfigTarget

TransitionConfigTarget<TContext, TEvent>: string | undefined | StateNode<TContext, any, TEvent>

Type parameters

TransitionDefinitionMap

TransitionDefinitionMap<TContext, TEvent>: {}

Type parameters

Type declaration

TransitionTarget

TransitionTarget<TContext, TEvent>: SingleOrArray<string | StateNode<TContext, any, TEvent>>

Type parameters

TransitionTargets

TransitionTargets<TContext>: Array<string | StateNode<TContext, any>>

Type parameters

  • TContext

TransitionsConfig

TransitionsConfig<TContext, TEvent>: TransitionsConfigMap<TContext, TEvent> | TransitionsConfigArray<TContext, TEvent>

Type parameters

TransitionsConfigArray

TransitionsConfigArray<TContext, TEvent>: Array<(TransitionConfig<TContext, TEvent> & { event: "" }) | (TransitionConfig<TContext, TEvent> & { event: "*" })>

Type parameters

TransitionsConfigMap

TransitionsConfigMap<TContext, TEvent>: {} & { ?: TransitionConfigOrTarget<TContext, TEvent> } & { *?: TransitionConfigOrTarget<TContext, TEvent> }

Type parameters

ValueFromStateGetter

ValueFromStateGetter<T, TContext, TEvent>: (state: State<TContext, TEvent>) => T

Type parameters

Type declaration

    • (state: State<TContext, TEvent>): T
    • Parameters

      • state: State<TContext, TEvent>

      Returns T

Variables

Const DEFAULT_GUARD_TYPE

DEFAULT_GUARD_TYPE: DefaultGuardType = "xstate.guard"

Const EMPTY_ACTIVITY_MAP

EMPTY_ACTIVITY_MAP: ActivityMap

Const EMPTY_OBJECT

EMPTY_OBJECT: {}

Type declaration

Const IS_PRODUCTION

IS_PRODUCTION: boolean = process.env.NODE_ENV === 'production'

Const NULL_EVENT

NULL_EVENT: "" = ""

Const STATE_DELIMITER

STATE_DELIMITER: "." = "."

Const STATE_IDENTIFIER

STATE_IDENTIFIER: "#" = "#"

Const TARGETLESS_KEY

TARGETLESS_KEY: "" = ""

Const WILDCARD

WILDCARD: "*" = "*"

Const after

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

    Parameters

    • delayRef: number | string

      The delay in milliseconds

    • Optional id: undefined | string

      The state node ID where this event is handled

    Returns string

Const children

children: Map<string, Actor<any, AnyEventObject>> = new Map<string, Actor>()

Const choose

Const doneState

doneState: DoneState = ActionTypes.DoneState

Const error

Const errorExecution

errorExecution: ErrorExecution = ActionTypes.ErrorExecution

Const errorPlatform

errorPlatform: ErrorPlatform = ActionTypes.ErrorPlatform

Const init

init: Init = ActionTypes.Init

Const initEvent

initEvent: Event<{ type: Init }> = toSCXMLEvent({ type: actionTypes.init })

Const invoke

invoke: Invoke = ActionTypes.Invoke

Const log

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

    Parameters

    • Default value expr: string | LogExpr<TContext, TEvent> = defaultLogExpr

      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.
    • Optional label: undefined | string

      The label to give to the logged expression.

    Returns LogAction<TContext, TEvent>

Const nullEvent

nullEvent: NullEvent = ActionTypes.NullEvent

Const pure

Const raise

  • 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 RaiseAction<TEvent> | SendAction<TContext, AnyEventObject, 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<TSentEvent> | SendExpr<TContext, TEvent, TSentEvent>

      The event to send.

    • Optional options: SendActionOptions<TContext, TEvent>

      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.
      • to - The target of this event (by default, the machine the event was sent from).

    Returns SendAction<TContext, TEvent, TSentEvent>

Const serviceStack

serviceStack: (undefined | Interpreter<any, any, any, any>)[] = [] as Array<AnyInterpreter | undefined>

Maintains a stack of the current service in scope. This is used to provide the correct service to spawn().

Let sessionIdIndex

sessionIdIndex: number = 0

Const start

Const stop

  • stop<TContext, TEvent>(actorRef: string | ActivityDefinition<TContext, TEvent> | Expr<TContext, TEvent, string | { id: string }>): StopAction<TContext, TEvent>

Const symbolObservable

symbolObservable: any = (() =>(typeof Symbol === 'function' && (Symbol as any).observable) ||'@@observable')()

Const uniqueId

uniqueId: (Anonymous function) = (() => {let currentId = 0;return () => {currentId++;return currentId.toString(16);};})()

Const update

update: Update = ActionTypes.Update

Functions

Machine

Const assign

bindActionToState

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 consume

  • consume<T, TService>(fn: (service: TService) => T): T
  • Type parameters

    Parameters

    • fn: (service: TService) => T
        • (service: TService): T
        • Parameters

          • service: TService

          Returns T

    Returns T

createCond

  • createCond<TContext, TEvent>(cond: string): (Anonymous function)
  • Type parameters

    Parameters

    • cond: string

    Returns (Anonymous function)

Const createDefaultOptions

createDeferredActor

  • createDeferredActor(entity: Spawnable, id: string, data?: any): Actor

createInvocableActor

  • Creates a deferred actor that is able to be invoked given the provided invocation information in its .meta value.

    Type parameters

    Parameters

    Returns Actor

createMachine

  • createMachine<TModel, TContext, TEvent, TTypestate>(config: MachineConfig<TContext, any, TEvent>, options?: Partial<MachineOptions<TContext, TEvent>>): StateMachine<TContext, any, TEvent, TTypestate>
  • createMachine<TContext, TEvent, TTypestate>(config: MachineConfig<TContext, any, TEvent>, options?: Partial<MachineOptions<TContext, TEvent>>): StateMachine<TContext, any, TEvent, TTypestate>

createModel

  • createModel<TContext, TEvent>(initialContext: TContext): Model<TContext, TEvent, never>
  • createModel<TContext, TModelCreators, TFinalModelCreators>(initialContext: TContext, creators: TModelCreators): Model<TContext, Cast<EventFromEventCreators<Prop<TFinalModelCreators, "events">>, EventObject>, TFinalModelCreators>

createNullActor

  • createNullActor(id: string): Actor

createSchema

  • createSchema<T>(schema?: any): T
  • Type parameters

    • T

    Parameters

    • Optional schema: any

    Returns T

Const defaultLogExpr

  • defaultLogExpr<TContext, TEvent>(context: TContext, event: TEvent): { context: TContext; event: TEvent }
  • Type parameters

    Parameters

    • context: TContext
    • event: TEvent

    Returns { context: TContext; event: TEvent }

    • context: TContext
    • event: TEvent

delayToMs

  • delayToMs(delay?: string | number): number | undefined
  • Parameters

    • Optional delay: string | number

    Returns number | undefined

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

each

escalate

  • Escalates an error by sending it as an event to this machine's parent.

    Type parameters

    Parameters

    • errorData: TErrorData | ExprWithMeta<TContext, TEvent, TErrorData>

      The error data to send, or the expression function that takes in the context, event, and meta, and returns the error data to send.

    • Optional options: SendActionOptions<TContext, TEvent>

      Options to pass into the send action creator.

    Returns SendAction<TContext, TEvent, AnyEventObject>

Const evaluateExecutableContent

  • evaluateExecutableContent<TContext, TEvent>(context: TContext, _ev: TEvent, meta: SCXMLEventMeta<TEvent>, body: string): any

evaluateGuard

  • evaluateGuard<TContext, TEvent>(machine: StateNode<TContext, any, TEvent, any>, guard: Guard<TContext, TEvent>, context: TContext, _event: Event<TEvent>, state: State<TContext, TEvent>): boolean
  • Type parameters

    Parameters

    • machine: StateNode<TContext, any, TEvent, any>
    • guard: Guard<TContext, TEvent>
    • context: TContext
    • _event: Event<TEvent>
    • state: State<TContext, TEvent>

    Returns boolean

executableContent

  • executableContent(elements: XMLElement[]): any
  • Parameters

    • elements: XMLElement[]

    Returns any

flatten

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

    • T

    Parameters

    • array: Array<T | T[]>

    Returns T[]

forwardTo

  • Forwards (sends) an event to a specified service.

    Type parameters

    Parameters

    • target: Required<SendActionOptions<TContext, TEvent>>["to"]

      The target service to forward the event to.

    • Optional options: SendActionOptions<TContext, TEvent>

      Options to pass into the send action creator.

    Returns SendAction<TContext, TEvent, AnyEventObject>

getActionFunction

getActionType

getAdjList

getAllStateNodes

  • getAllStateNodes<TC, TE>(stateNode: StateNode<TC, any, TE, any>): Array<StateNode<TC, any, TE, any>>

getAttribute

  • getAttribute(element: XMLElement, attribute: string): string | number | undefined
  • Parameters

    • element: XMLElement
    • attribute: string

    Returns string | number | undefined

getChildren

getConfiguration

  • getConfiguration<TC, TE>(prevStateNodes: Iterable<StateNode<TC, any, TE, any>>, stateNodes: Iterable<StateNode<TC, any, TE, any>>): Iterable<StateNode<TC, any, TE, any>>

getDevTools

getEventType

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

getGlobal

  • getGlobal(): undefined | (Window & globalThis) | (Global & globalThis)
  • Returns undefined | (Window & globalThis) | (Global & globalThis)

getStateNodeId

  • getStateNodeId(stateNode: StateNode): string

getTargets

  • getTargets(targetAttr?: string | number): string[] | undefined
  • Parameters

    • Optional targetAttr: string | number

    Returns string[] | undefined

getValue

getValueFromAdj

has

  • has<T>(iterable: Iterable<T>, item: T): boolean
  • Type parameters

    • T

    Parameters

    • iterable: Iterable<T>
    • item: T

    Returns boolean

indexedRecord

  • indexedRecord<T>(items: T[], identifier: string | ((item: T) => string)): Record<string, T>
  • Type parameters

    • T: {}

    Parameters

    • items: T[]
    • identifier: string | ((item: T) => string)

    Returns Record<string, T>

interpret

  • interpret<TContext, TStateSchema, TEvent, TTypestate>(machine: StateMachine<TContext, TStateSchema, TEvent, TTypestate>, options?: Partial<InterpreterOptions>): Interpreter<TContext, TStateSchema, TEvent, TTypestate>
  • Creates a new Interpreter instance for the given machine with the provided options, if any.

    Type parameters

    Parameters

    • machine: StateMachine<TContext, TStateSchema, TEvent, TTypestate>

      The machine to interpret

    • Optional options: Partial<InterpreterOptions>

      Interpreter options

    Returns Interpreter<TContext, TStateSchema, TEvent, TTypestate>

isActionObject

  • isActionObject<TContext, TEvent>(action: Action<TContext, TEvent>): action is ActionObject<TContext, TEvent>
  • Type parameters

    Parameters

    • action: Action<TContext, TEvent>

    Returns action is ActionObject<TContext, TEvent>

isActor

  • isActor(value: any): value is Actor
  • Parameters

    • value: any

    Returns value is Actor

isArray

  • isArray(value: any): value is any[]
  • Parameters

    • value: any

    Returns value is any[]

isBuiltInEvent

  • isBuiltInEvent(eventType: EventType): boolean

isFunction

  • isFunction(value: any): value is Function
  • Parameters

    • value: any

    Returns value is Function

isInFinalState

  • isInFinalState<TC, TE>(configuration: Array<StateNode<TC, any, TE, any>>, stateNode: StateNode<TC, any, TE, any>): boolean

Const isLeafNode

  • isLeafNode(stateNode: StateNode<any, any, any, any>): boolean

isMachine

  • isMachine(value: any): value is StateMachine<any, any, any>
  • Parameters

    • value: any

    Returns value is StateMachine<any, any, any>

isObservable

  • isObservable<T>(value: any): value is Subscribable<T>
  • Type parameters

    • T

    Parameters

    • value: any

    Returns value is Subscribable<T>

isPromiseLike

  • isPromiseLike(value: any): value is PromiseLike<any>
  • Parameters

    • value: any

    Returns value is PromiseLike<any>

isSpawnedActor

  • isSpawnedActor(item: any): item is SpawnedActorRef<any>
  • Parameters

    • item: any

    Returns item is SpawnedActorRef<any>

isState

  • isState<TContext, TEvent, TStateSchema, TTypestate>(state: object | string): state is State<TContext, TEvent, TStateSchema, TTypestate>
  • Type parameters

    Parameters

    • state: object | string

    Returns state is State<TContext, TEvent, TStateSchema, TTypestate>

Const isStateId

  • isStateId(str: string): boolean

isStateLike

  • isStateLike(state: any): state is StateLike<any>
  • Parameters

    • state: any

    Returns state is StateLike<any>

isString

  • isString(value: any): value is string
  • Parameters

    • value: any

    Returns value is string

jsonify

  • jsonify<T>(value: T): T
  • Type parameters

    • T: Record<string, any>

    Parameters

    • value: T

    Returns T

keys

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

    • T: object

    Parameters

    • value: T

    Returns Array<keyof T & string>

machineToJSON

  • machineToJSON(stateNode: StateNode): StateNodeConfig

mapAction

  • mapAction<TContext, TEvent>(element: XMLElement): ActionObject<TContext, TEvent>

mapActions

  • mapActions<TContext, TEvent>(elements: XMLElement[]): Array<ActionObject<TContext, TEvent>>

mapContext

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

mapFilterValues

  • mapFilterValues<T, P>(collection: {}, iteratee: (item: T, key: string, collection: {}) => P, predicate: (item: T) => boolean): {}
  • Type parameters

    • T

    • P

    Parameters

    • collection: {}
      • [key: string]: T
    • iteratee: (item: T, key: string, collection: {}) => P
        • (item: T, key: string, collection: {}): P
        • Parameters

          • item: T
          • key: string
          • collection: {}
            • [key: string]: T

          Returns P

    • predicate: (item: T) => boolean
        • (item: T): boolean
        • Parameters

          • item: T

          Returns boolean

    Returns {}

    • [key: string]: P

mapState

  • mapState(stateMap: {}, stateId: string): any
  • Parameters

    • stateMap: {}
      • [stateId: string]: any
    • stateId: string

    Returns any

mapValues

  • mapValues<T, P, O>(collection: O, iteratee: (item: O[keyof O], key: keyof O, collection: O, i: number) => P): {}
  • Type parameters

    • T

    • P

    • O: {}

    Parameters

    • collection: O
    • iteratee: (item: O[keyof O], key: keyof O, collection: O, i: number) => P
        • (item: O[keyof O], key: keyof O, collection: O, i: number): P
        • Parameters

          • item: O[keyof O]
          • key: keyof O
          • collection: O
          • i: number

          Returns P

    Returns {}

matchState

matchesState

nestedPath

  • nestedPath<T>(props: string[], accessorProp: keyof T): (object: T) => T
  • 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 (object: T) => T

      • (object: T): T
      • Parameters

        • object: T

        Returns T

nextEvents

  • nextEvents<TC, TE>(configuration: Array<StateNode<TC, any, TE>>): Array<TE["type"]>

normalizeTarget

  • normalizeTarget<TContext, TEvent>(target: SingleOrArray<string | StateNode<TContext, any, TEvent>> | undefined): Array<string | StateNode<TContext, any, TEvent>> | undefined

parse

  • parse(machineString: string): StateNodeConfig
  • Parameters

    • machineString: string

    Returns StateNodeConfig

partition

  • partition<T, A, B>(items: T[], predicate: (item: T) => item is A): []
  • Type parameters

    • T

    • A: T

    • B: T

    Parameters

    • items: T[]
    • predicate: (item: T) => item is A
        • (item: T): item is A
        • Parameters

          • item: T

          Returns item is A

    Returns []

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

pathsToStateValue

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

Const provide

  • provide<T, TService>(service: TService | undefined, fn: (service: TService | undefined) => T): T
  • Type parameters

    Parameters

    • service: TService | undefined
    • fn: (service: TService | undefined) => T
        • (service: TService | undefined): T
        • Parameters

          • service: TService | undefined

          Returns T

    Returns T

registerService

reportUnhandledExceptionOnInvocation

  • reportUnhandledExceptionOnInvocation(originalError: any, currentError: any, id: string): void
  • Parameters

    • originalError: any
    • currentError: any
    • id: string

    Returns void

resolveActions

  • resolveActions<TContext, TEvent>(machine: StateNode<TContext, any, TEvent, any>, currentState: State<TContext, TEvent> | undefined, currentContext: TContext, _event: Event<TEvent>, actions: Array<ActionObject<TContext, TEvent>>): []
  • Type parameters

    Parameters

    • machine: StateNode<TContext, any, TEvent, any>
    • currentState: State<TContext, TEvent> | undefined
    • currentContext: TContext
    • _event: Event<TEvent>
    • actions: Array<ActionObject<TContext, TEvent>>

    Returns []

Const resolveLog

resolveRaise

resolveSend

Const resolveSpawnOptions

  • resolveSpawnOptions(nameOrOptions?: string | SpawnOptions): { name: string }

resolveStop

respond

scxmlToMachine

sendParent

  • Sends an event to this machine's parent.

    Type parameters

    Parameters

    • event: Event<TSentEvent> | SendExpr<TContext, TEvent, TSentEvent>

      The event to send to the parent machine.

    • Optional options: SendActionOptions<TContext, TEvent>

      Options to pass into the send event.

    Returns SendAction<TContext, TEvent, TSentEvent>

sendUpdate

  • sendUpdate<TContext, TEvent>(): SendAction<TContext, TEvent, { type: Update }>

sequence

  • sequence<TStateSchema, TEvent>(items: Array<keyof TStateSchema["states"]>, options?: Partial<SequencePatternOptions<TEvent>>): { initial: keyof TStateSchema["states"]; states: StatesConfig<any, TStateSchema, TEvent> }

spawn

stateValuesEqual

stringify

stringifyFunction

toActionObject

Const toActionObjects

toActivityDefinition

toArray

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

    • T

    Parameters

    • value: T[] | T | undefined

    Returns T[]

toArrayStrict

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

    • T

    Parameters

    • value: T[] | T

    Returns T[]

toConfig

toEventObject

  • toEventObject<TEvent>(event: Event<TEvent>, payload?: EventData): TEvent

toGuard

  • toGuard<TContext, TEvent>(condition?: Condition<TContext, TEvent>, guardMap?: Record<string, ConditionPredicate<TContext, TEvent>>): Guard<TContext, TEvent> | undefined

toInvokeDefinition

toInvokeSource

toMachine

toObserver

  • toObserver<T>(nextHandler: Observer<T> | ((value: T) => void), errorHandler?: undefined | ((error: any) => void), completionHandler?: undefined | (() => void)): Observer<T>
  • Type parameters

    • T

    Parameters

    • nextHandler: Observer<T> | ((value: T) => void)
    • Optional errorHandler: undefined | ((error: any) => void)
    • Optional completionHandler: undefined | (() => void)

    Returns Observer<T>

toSCXMLEvent

  • toSCXMLEvent<TEvent>(event: Event<TEvent> | Event<TEvent>, scxmlEvent?: Partial<Event<TEvent>>): Event<TEvent>

toStatePath

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

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

    Returns string[]

toStatePaths

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

toStateValue

toTransitionConfigArray

toggle

  • toggle<TEventType>(onState: string, offState: string, eventType: TEventType): Record<string, AtomicStateNodeConfig<any, { type: TEventType }>>
  • Type parameters

    • TEventType: string

    Parameters

    • onState: string
    • offState: string
    • eventType: TEventType

    Returns Record<string, AtomicStateNodeConfig<any, { type: TEventType }>>

updateContext

  • updateContext<TContext, TEvent>(context: TContext, _event: Event<TEvent>, assignActions: Array<AssignAction<TContext, TEvent>>, state?: State<TContext, TEvent>): TContext
  • Type parameters

    Parameters

    • context: TContext
    • _event: Event<TEvent>
    • assignActions: Array<AssignAction<TContext, TEvent>>
    • Optional state: State<TContext, TEvent>

    Returns TContext

updateHistoryStates

updateHistoryValue

Const validateArrayifiedTransitions

  • validateArrayifiedTransitions<TContext>(stateNode: StateNode<any, any, any, any>, event: string, transitions: Array<TransitionConfig<TContext, EventObject> & { event: string }>): void

Let warn

  • warn(): void

Object literals

Const DEFAULT_SPAWN_OPTIONS

DEFAULT_SPAWN_OPTIONS: object

autoForward

autoForward: boolean = false

sync

sync: boolean = false

Const actions

actions: object

after

after: after

assign

assign: assign

cancel

cancel: cancel

choose

choose: choose

done

done: done

escalate

escalate: escalate

forwardTo

forwardTo: forwardTo

log

log: log

pure

pure: pure

raise

raise: raise

respond

respond: respond

send

send: send

sendParent

sendParent: sendParent

sendUpdate

sendUpdate: sendUpdate

start

start: start

stop

stop: stop

Const defaultOptions

defaultOptions: object

deferEvents

deferEvents: false = false

Const defaultSequencePatternOptions

defaultSequencePatternOptions: object

nextEvent

nextEvent: string = "NEXT"

prevEvent

prevEvent: string = "PREV"

Const registry

registry: object

bookId

  • bookId(): string

free

  • free(id: string): void

get

register

Generated using TypeDoc