.after()

The .after() method defines explicit dependencies between workflow steps, enabling branching and merging paths in your workflow execution.

Usage

Basic Branching

workflow
  .step(stepA)
    .then(stepB)
  .after(stepA)  // Create new branch after stepA completes
    .step(stepC);

Merging Multiple Branches

workflow
  .step(stepA)
    .then(stepB)
  .step(stepC)
    .then(stepD)
  .after([stepB, stepD])  // Create a step that depends on multiple steps
    .step(stepE);

Parameters

steps:

Step | Step[]
A single step or array of steps that must complete before continuing

Returns

workflow:

Workflow
The workflow instance for method chaining

Examples

Single Dependency

workflow
  .step(fetchData)
  .then(processData)
  .after(fetchData)  // Branch after fetchData
  .step(logData);

Multiple Dependencies (Merging Branches)

workflow
  .step(fetchUserData)
  .then(validateUserData)
  .step(fetchProductData)
  .then(validateProductData)
  .after([validateUserData, validateProductData])  // Wait for both validations to complete
  .step(processOrder);