arrow-fx-coroutines / arrow.fx.coroutines / ForkConnected
suspend fun <A> ~~ForkConnected~~(ctx:
CoroutineContext
= Dispatchers.Default, f: suspend () -> A):
Fiber
<A>
Deprecated: Use async with KotlinX Coroutines Structured Concurrency
Launches a new suspendable cancellable coroutine within a Fiber.
It does so by connecting the created Fiber’s cancellation to the callers suspend
scope.
If the caller of ForkConnected
gets cancelled, then this Fiber will also get cancelled.
import arrow.fx.coroutines.*
suspend fun main(): Unit {
val parent = ForkConnected {
ForkConnected { // cancellation connected to parent
onCancel({ never<Unit>() }) {
println("I got cancelled by my parent")
}
}
}
sleep(1.seconds)
parent.cancel()
}
You can Fiber.join or Fiber.cancel the computation. Cancelling this Fiber will not cancel its parent.
Do you like Arrow?
✖