Class Action<TContext, TEventData>

A generic class for defining actions within an XState state machine context. It encapsulates action logic and associates it with a unique identifier. Actions defined using this class can be used for handling state transitions or performing side effects in response to events in the state machine.

Example usage:

const action = new Action<MyContext>((context, event) => {
console.log('Action executed', context, event);
}, 'saveData');
console.log(action.ref); // Outputs the unique ID of the action, incorporating the name 'saveData'

Typeparam

TContext The type of the state context within which the action operates.

Typeparam

TEventData The type of the event within which the action operates.

Type Parameters

  • TContext extends Record<string, any> = Record<string, any>

  • TEventData extends Record<string, any> = Record<string, any>

Constructors

Properties

Accessors

Methods

Constructors

Properties

id: string
params: ActionsParams<TContext, TEventData>

Accessors

  • get ref(): string
  • Provides the unique identifier of this action instance. The identifier includes the action's name and a UUID, enhancing traceability and uniqueness within a state machine.

    Returns string

    A string that serves as the unique identifier of this action instance.

Methods

Generated using TypeDoc