Skip to Content

Workflow.branch()

The .branch() method creates conditional branches between workflow steps, allowing for different paths to be taken based on the result of a previous step.

Usage

workflow.branch([ [async ({ context }) => true, stepOne], [async ({ context }) => false, stepTwo], ]);

Parameters

steps:

[() => boolean, Step]
An array of tuples, each containing a condition function and a step to execute if the condition is true

Returns

workflow:

NewWorkflow
The workflow instance for method chaining