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.
branchId, nextStepId), and a step:branch event is emitted before the target step for better observability.
Tuple variant
Best practices
- Make business rules explicit inside
resolveBranchto simplify maintenance. - Emit events with
context.emitto document decisions made in each branch. - Combine
.conditions()withcreateParallelSteporcreateForEachStepto build hybrid pipelines.