```fun childIOError() = setState { onIO { ...
# arrow
j
Copy code
fun childIOError() = setState {
        onIO {
            error("Boom on IO")
        }
    }
Following docs, in
uniflow
all actions can run on a coroutine using a DSL prepared for it, functions like
onIO
onMain
,
onDefault
just translate to standard
withContext(IO)
,
withContext(Main)
,
withContext(Default)
. Same for
launchOnIO
,
launchOnMain
,
launchOnDefault
if you need to launch it not just switch the dispatcher. If you look at how the DSL functions are defined, you’ll find this: https://github.com/uniflow-kt/uniflow-kt/blob/5152c197131c7f9d8b3129a37017671c4aea49ae/uniflow-core/src/main/kotlin/io/uniflow/core/threading/Threading.kt Launch ones are defined over a coroutine scope, like:
fun CoroutineScope.launchOnIO(block: suspend CoroutineScope.() -> Unit) = launch(<http://UniFlowDispatcher.dispatcher.io|UniFlowDispatcher.dispatcher.io>(), block = block)
Those get
block
as a suspend function so you can pass an arrow `IO`one there by calling `suspended() or suspendCancellable()`as suggested by Alberto. Alternatively you can write an “overload” that enforces
block
to be an arrow
IO
instead, so you have both syntax available. Then you can `launch`the IO task inside with the new extension functions to run the passed IO scoped to the receiver scope. (This is just available starting on the snapshot 0.10.5) For the
onXXX
ones are suspend functions you can wrap into
IO.effect {}
🔝 2
☝️ 3