arrow-fx-coroutines / arrow.fx.coroutines / uncancellable

uncancellable

suspend inline fun <A> ~~uncancellable~~(crossinline f: suspend () -> A): A Deprecated: Use withContext(NonCancellable) from KotlinX insteed

Runs f in an uncancellable manner. If f gets cancelled, it will back-pressure the cancelling operation until finished.

import arrow.fx.coroutines.*

suspend fun main(): Unit {
  //sampleStart
  val n = timeOutOrNull(10.milliseconds) {
    uncancellable { sleep(100.milliseconds) }
  } // takes 100.milliseconds, and returns null

  //sampleEnd
  println("n: $n")
}

Do you like Arrow?

Arrow Org
<