Skip to main content

Conditional Branching

Fork operations enable workflows to select a branch based on a criteria. It's equivalent to if instructions but allow for static rendering of the workflow.

val doA = WIO.pure(MyState(1)).autoNamed
val doB = WIO.pure(MyState(2)).autoNamed

val fork: WIO[MyState, Nothing, MyState] =
WIO
.fork[MyState]
.matchCondition(_.counter > 0, "Is counter positive?")(
onTrue = doA,
onFalse = doB,
)
Rendering Outputs

Drafting Support

Branching comes with drafting support.

val approveStep = WIO.draft.step("Approve")
val rejectStep = WIO.draft.step("Reject")

val approvalWorkflow = WIO.draft.choice("Review Decision")(
"Approved" -> approveStep,
"Rejected" -> rejectStep,
)
Rendering Outputs