Don’t worry, thanks for asking. Here’s an example ...
# arrow
j
Don’t worry, thanks for asking. Here’s an example of a potential overload you could write to ensure you can use the
launchOnXX
DSL but over IO functions.
Copy code
fun sideEffect(): IO<Error, Unit> = TODO()

// Overload to use uniflow dispatchers and get automatic cancellation of the IO task when the scope gets cancelled.
fun <E> CoroutineScope.launchOnIO(
    block: IO<E, Unit>,
    callback: (IOResult<E, Unit>) -> Unit
  ) =
    launch(<http://UniFlowDispatcher.dispatcher.io|UniFlowDispatcher.dispatcher.io>()) {
      block.unsafeRunScoped(this, callback)
    }

So you can call it like:

scope.launchOnIO(sideEffect()) { cb ->
    cb.fold(
      ifException = { TODO() },
      ifLeft = { TODO() },
      ifSuccess = { TODO() }
    )
  }