Skip to main content

Running Side Effects

Without Error

Code

val doThings: WIO[MyState, Nothing, MyState] =
WIO
.runIO[MyState](state => IO(MyEvent()))
.handleEvent((state, event) => MyState(state.counter + 1))
.autoNamed

BPMN

run-io.svg

Model

{
"error" : null,
"name" : "Do Things",
"_type" : "RunIO"
}

With Error

Code

val doThingsWithError: WIO[MyState, MyError, MyState] =
WIO
.runIO[MyState](state => IO(MyEvent()))
.handleEventWithError((state, event) =>
if (true) MyState(state.counter + 1).asRight
else MyError().asLeft,
)
.autoNamed

BPMN

run-io.svg

Model

{
"error" : {
"name" : "My Error"
},
"name" : "Do Things With Error",
"_type" : "RunIO"
}