arrow-fx-coroutines / arrow.fx.coroutines / Promise / get

get

abstract suspend fun get(): A

Gets the promised value or throws. Use attempt when throwing is not required. Suspends until the promised value is available.

import arrow.fx.coroutines.*

suspend fun main(): Unit {
  //sampleStart
  val promise = Promise<Int>()

  timeOutOrNull(2.seconds) {
    promise.get()
  }.also { println("I timed out: $it") }

  promise.complete(5)
  println(promise.get())
  //sampleEnd
}

Do you like Arrow?

Arrow Org
<