Class Actor<TEvent, TState, TContext>

An "actor" is a client-side representation of a machine instance.

This is intended to closely mimic the notion of an XState actor and should be compatible with any XState utilities that accept actors.

Type Parameters

  • TEvent extends Exclude<Event, string> = any

  • TState extends StateValue = any

  • TContext extends Record<string, unknown> = any

Hierarchy

  • Actor

Constructors

  • Type Parameters

    • TEvent extends {
          type: string;
          [key: string]: unknown;
      } = any

    • TState extends string | {
          [key: string]: components["schemas"]["StateValue"] | undefined;
      } = any

    • TContext extends Record<string, unknown> = any

    Parameters

    • client: StateBackedClient
    • machineName: string
    • instanceName: string
    • state: {
          done: boolean;
          publicContext?: {
              [key: string]: unknown;
          };
          state: string | {
              [key: string]: components["schemas"]["StateValue"] | undefined;
          };
          tags: string[];
          ts: number;
      }
      • done: boolean

        Description

        Is the state machine complete

      • Optional publicContext?: {
            [key: string]: unknown;
        }

        Description

        The public context of the machine instance.

        This includes all context under the public key.

        • [key: string]: unknown
      • state: string | {
            [key: string]: components["schemas"]["StateValue"] | undefined;
        }
      • tags: string[]

        Description

        Array of tags for the current states

      • ts: number

        Description

        Timestamp for when the state was created

    • Optional signal: AbortSignal

    Returns Actor<TEvent, TState, TContext>

Properties

id: string

The actor's id ("machineName/instanceName")

inFlightEvents: (TEvent | ExtractType<TEvent> | TEvent["type"])[] = []
instanceName: string
latestReceivedTs: number = 0
machineName: string
signal?: AbortSignal
state: ActorState<TState, TContext>
subscribers: Observer<ActorState<TState, TContext>>[] = []
unsubscribe: Unsubscribe

Methods

  • Parameters

    • state: {
          done: boolean;
          publicContext?: {
              [key: string]: unknown;
          };
          state: string | {
              [key: string]: components["schemas"]["StateValue"] | undefined;
          };
          tags: string[];
          ts: number;
      }
      • done: boolean

        Description

        Is the state machine complete

      • Optional publicContext?: {
            [key: string]: unknown;
        }

        Description

        The public context of the machine instance.

        This includes all context under the public key.

        • [key: string]: unknown
      • state: string | {
            [key: string]: components["schemas"]["StateValue"] | undefined;
        }
      • tags: string[]

        Description

        Array of tags for the current states

      • ts: number

        Description

        Timestamp for when the state was created

    • forceTrigger: boolean = false

    Returns void

Generated using TypeDoc