switchyard
    Preparing search index...

    Class Machine<S>Abstract

    Type Parameters

    Index
    "[INTERNAL]": {
        adopt(
            parent: Machine<unknown>,
            child: Machine<unknown>,
            systemId: string | undefined,
            invokedAs?: string,
        ): Interpreter;
    } = ...
    clock?: Clock

    Timers for @after. Tests assign manualClock(); it is inherited by subclasses.

    persist?: string[]

    Context fields snapshot() captures and restore() sets back.

    states?: EnumClass<State<never>>

    The root state enum, when it cannot be inferred from the decorators.

    strict: boolean = false

    Throw on an event the current state does not handle, instead of warning.

    • get can(): Can<S>

      m.can(FetchState.Loading): whether some event would now take the machine into the state; { via: m.retry } asks about that event alone. m.can.fetch: whether calling fetch() now would take a transition.

      Returns Can<S>

    • get system(): { get(systemId: string): Machine<unknown> | undefined }

      Actors registered by systemId anywhere in this machine's tree.

      Returns { get(systemId: string): Machine<unknown> | undefined }

    • Delivers { type, ...payload } to on(type) listeners outside the machine. type is a method of the machine, this.emit(this.factClosed), named factClosed; or that name as a string.

      Parameters

      • type: string | EmittedBy
      • payload: Record<string, unknown> = {}

      Returns void

    • m.on(m.factClosed, fn): listens for what this.emit(this.factClosed) delivers.

      Parameters

      • type: string | EmittedBy
      • listener: (event: { type: string; [key: string]: unknown }) => void

      Returns () => void

    • Sends an event to the machine that spawned or invoked this one.

      Parameters

      • event: string
      • ...args: unknown[]

      Returns void

    • Sends an event to a spawned or invoked actor by id.

      Parameters

      • id: string
      • event: string
      • ...args: unknown[]

      Returns void

    • Starts child as an actor of this machine, stopped when this one stops.

      Type Parameters

      Parameters

      • child: M
      • options: { id: string; systemId?: string }

      Returns M

    • Called after every event that took a transition, and once on start.

      Parameters

      • listener: (machine: this) => void

      Returns () => void