valtio-fsm
    Preparing search index...

    Interface InternalMachine<TState, TContext>

    Internal machine state structure

    interface InternalMachine<
        TState extends string,
        TContext extends Record<string, unknown>,
    > {
        context: TContext;
        contextListeners: Set<(context: TContext, changes: unknown[]) => void>;
        current: TState;
        eventHandlers: Record<string, Set<EventHandler<TContext>>>;
        historyEnabled: boolean;
        historySize: number;
        oneTimeEventHandlers: Record<string, Set<EventHandler<TContext>>>;
        previousContextSnapshot: unknown;
        stateCallbacks: Map<TState, Set<(context: TContext) => void>>;
        transitionListeners: Set<
            (from: TState, to: TState, payload?: unknown) => void,
        >;
    }

    Type Parameters

    • TState extends string

      String literal type representing valid states

    • TContext extends Record<string, unknown>

      Context data type for the state machine

    Index

    Properties

    context: TContext

    Current context data

    contextListeners: Set<(context: TContext, changes: unknown[]) => void>

    Set of context change listeners

    current: TState

    Current state

    eventHandlers: Record<string, Set<EventHandler<TContext>>>

    Map of event handlers by event name

    historyEnabled: boolean

    Whether history tracking is enabled

    historySize: number

    Maximum history size

    oneTimeEventHandlers: Record<string, Set<EventHandler<TContext>>>

    Map of one-time event handlers by event name

    previousContextSnapshot: unknown

    Snapshot of previous context for change detection

    stateCallbacks: Map<TState, Set<(context: TContext) => void>>

    Map of state-specific callbacks

    transitionListeners: Set<(from: TState, to: TState, payload?: unknown) => void>

    Set of transition listeners