Skip to main content

Loops

Code

val step1 = WIO.pure[MyState](MyState(1)).autoNamed()
val step2 = WIO.pure[MyState](MyState(1)).autoNamed()

val loop: WIO[MyState, Nothing, MyState] = WIO
.repeat(step1)
.untilSome(state => Some(state))
.onRestart(step2)
.named(
conditionName = "Is everything done?",
releaseBranchName = "Yes!",
restartBranchName = "No",
)
.done

BPMN

handle-error-with.svg

Model

{
"base" : {
"name" : "Step1",
"error" : null,
"_type" : "Pure"
},
"conditionName" : "Is everything done?",
"exitBranchName" : "Yes!",
"restartBranchName" : "No",
"onRestart" : {
"name" : "Step2",
"error" : null,
"_type" : "Pure"
},
"_type" : "Loop"
}