@thingts/fsm-engine - v1.2.1
    Preparing search index...

    Type Alias FsmActionApi<Events>

    The API exposed to actions via the fsm parameter.

    type FsmActionApi<Events extends EventMap> = {
        cancelAllTimers(): void;
        cancelTimer(key: TimerKey): void;
        dispatch<K extends string>(event: K, ...args: PayloadArgs<Events, K>): void;
        timer<K extends string>(params: TimerParams<Events, K>): void;
    }

    Type Parameters

    Index

    Methods

    • Cancels all previously scheduled timers. Use with caution!

      Returns void

    • Cancels a previously scheduled timer

      Parameters

      • key: TimerKey

      Returns void

    • Dispatches an event to the FSM. The event will be processed after the current action finishes.

      Type Parameters

      • K extends string

      Parameters

      Returns void

    • Schedules a timer to dispatch an event after a delay.

      Type Parameters

      • K extends string

      Parameters

      • params: TimerParams<Events, K>

        parameters object:

        • key (optional): a unique identifier for the timer. If not provided, the event will be used
        • event: the event to dispatch when the timer expires
        • payload: the payload to include with the dispatched event, iff the event has one
        • ms: delay duration in milliseconds, or Infinity for no expiration.
        • deadline: absolute expiration time, in performance.now() time.

        Exactly one of ms or deadline must be provided.

        If a timer with the same key already exists, it will be replaced with the new timer.

      Returns void