Skip to main content

Workflow.branch()

.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.

使用示例
Direct link to 使用示例

🌐 Usage example

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

参数
Direct link to 参数

🌐 Parameters

steps:

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

返回
Direct link to 返回

🌐 Returns

workflow:

NewWorkflow
The workflow instance for method chaining

🌐 Related