Hooks API Reference
Hooks allow you to subscribe to various events in the flow lifecycle.
FlowHooks<TInput>
ts
type FlowHooks<TInput> = {
onFlowStart?: (event: FlowStartEvent<TInput>) => void | Promise<void>;
onFlowComplete?: (event: FlowCompleteEvent<TInput>) => void | Promise<void>;
onFlowFail?: (event: FlowFailEvent<TInput>) => void | Promise<void>;
onStepStart?: (event: StepStartEvent<TInput>) => void | Promise<void>;
onStepComplete?: (event: StepCompleteEvent<TInput>) => void | Promise<void>;
onStepFail?: (event: StepFailEvent<TInput>) => void | Promise<void>;
onCompensate?: (event: CompensateEvent<TInput>) => void | Promise<void>;
onCompensateComplete?: (event: CompensateCompleteEvent<TInput>) => void | Promise<void>;
};Event Objects
All hook events share some common properties:
flowName: stringinput: TInputcontext: FlowContext<TInput>
FlowCompleteEvent
Adds:
result: FlowResult
StepStartEvent
Adds:
stepName: string
StepCompleteEvent
Adds:
stepName: stringresult: StepResult
StepFailEvent
Adds:
stepName: stringerror: StepResult
CompensateEvent
Adds:
stepName: stringerror: unknown(the error that triggered the compensation)