Skip to main content
Use createConditionStep to take dynamic decisions. The .conditions() method attaches a step whose resolveBranch returns either a branch index (tuple mode) or an explicit key (object mode). Returning undefined resumes the linear sequence.
Each branch appears in the run snapshots (branchId, nextStepId), and a step:branch event is emitted before the target step for better observability.

Tuple variant

Choose this form when order matters more than branch naming (for example reusing an array of steps).

Best practices

  • Make business rules explicit inside resolveBranch to simplify maintenance.
  • Emit events with context.emit to document decisions made in each branch.
  • Combine .conditions() with createParallelStep or createForEachStep to build hybrid pipelines.