Documentation
    Preparing search index...

    Class WorkflowStateMachine<TState, TEvent, TContext>

    State machine managing linear forward-only workflows. Handled via explicit events and transitions.

    Type Parameters

    • TState
    • TEvent
    • TContext

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    context: TContext
    currentState: TState
    history: TState[] = []
    transitions: WorkflowTransition<TState, TEvent, TContext>[] = []

    Methods

    • Returns the history trace of all states traversed.

      Returns TState[]

      Array of state transitions.

    • Performs a transition to a new state if the event matches and the guard function passes.

      Parameters

      • event: TEvent

        The triggering event.

      Returns Promise<boolean>

      A promise resolving to true if the transition succeeded, false otherwise.

    • Merges new properties into the state machine's execution context.

      Parameters

      • newContext: Partial<TContext>

        Partial context to merge.

      Returns void