Skip to main content

.after()

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

UsageDirect link to Usage

Basic BranchingDirect link to Basic Branching

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

Merging Multiple BranchesDirect link to 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);

ParametersDirect link to Parameters

steps:

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

ReturnsDirect link to Returns

workflow:

LegacyWorkflow
The workflow instance for method chaining

ExamplesDirect link to Examples

Single DependencyDirect link to Single Dependency

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

Multiple Dependencies (Merging Branches)Direct link to Multiple Dependencies (Merging Branches)

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