There shouldn’t be any need for fiber and bracket....
# arrow
s
There shouldn’t be any need for fiber and bracket.
IO
can run in a cancellable way with a cancelable reference
typealias Disposeable = () -> Unit
. Whenever the coroutine gets cancelled you can also cancel the underlying
IO
using that reference.
Copy code
fun <A> IOOf<A>.suspendCancellable() : Either<Throwable, A> =
 suspendCancellableCoroutine { continuation ->
    val disposable = fix().unsafeRunSyncCancellable {  continuation.resume(it) }
    continuation.invokeOnCancellation { disposable.invoke() }
  }
t
thank you 🙂
👍 1