arrow-fx-coroutines / arrow.fx.coroutines / timeOutOrNull

timeOutOrNull

suspend fun <A> ~~timeOutOrNull~~(duration: Duration, fa: suspend () -> A): A? Deprecated: use withTimeOutOrNull

Returns the result of fa within the specified duration or returns null.

import arrow.fx.coroutines.*

suspend fun main(): Unit {
  timeOutOrNull(2.seconds) {
    sleep(5.seconds)
    "Message from lazy task"
  }.also(::println)

  timeOutOrNull(2.seconds) {
    "Message from fast task"
  }.also(::println)
}

Do you like Arrow?

Arrow Org
<