footprintjs - v11.2.0
    Preparing search index...

    Interface PausableHandler<TScope, TInput, TPauseData>

    Handler for a pausable stage — has two phases: execute and resume.

    execute runs the first time. Return any non-void value to pause (that value becomes the checkpoint's pauseData); return void/undefined to continue normally. resume runs when the flowchart is resumed. It receives the resume input.

    Both phases receive the same scope. After execute pauses, the scope state is preserved in the checkpoint. On resume, the scope is restored before calling resume.

    .addPausableFunction('ApproveOrder', {
    execute: async (scope) => {
    scope.orderId = '123';
    scope.amount = 299;
    return { question: `Approve $${scope.amount} refund?` };
    },
    resume: async (scope, input) => {
    scope.approved = input.approved;
    scope.approver = input.approver;
    },
    }, 'approve-order', 'Manager approval gate')

    // Later — resume with human's answer
    await executor.resume(checkpoint, { approved: true, approver: 'Jane' });
    interface PausableHandler<TScope = any, TInput = unknown, TPauseData = unknown> {
        execute: (
            scope: TScope,
        ) => void | TPauseData | Promise<void | TPauseData>;
        resume: (scope: TScope, input: TInput) => void | Promise<void>;
    }

    Type Parameters

    • TScope = any
    • TInput = unknown
    • TPauseData = unknown
    Index
    execute: (scope: TScope) => void | TPauseData | Promise<void | TPauseData>

    First-run phase. Return data to pause, or void/undefined to continue normally.

    Any non-void return value becomes the pauseData in the checkpoint. The consumer defines the TPauseData type — the FE uses it to render the right UI (form fields, approval buttons, etc.).

    // TPauseData = { question: string; riskLevel: string }
    const handler: PausableHandler<MyState, { approved: boolean }, { question: string; riskLevel: string }> = {
    execute: async (scope) => {
    return { question: `Approve order ${scope.orderId}?`, riskLevel: 'high' };
    },
    resume: async (scope, input) => {
    scope.approved = input.approved;
    },
    };
    resume: (scope: TScope, input: TInput) => void | Promise<void>

    Resume phase. Called with the resume input when execution continues.

    The scope is restored from the checkpoint's sharedState. Writes during resume are committed and visible to subsequent stages.