John
12/12/2019, 6:46 PMfun suspend getCar(): Car {
val returnedCard
fetcher.getCar({ car ->
returnedCar = car
})
// await while car is fetched ???
return returnedCar
}
Ruckus
12/12/2019, 6:49 PMsuspendCoroutine
and suspendCancellableCoroutine
.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/suspend-coroutine.html
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/suspend-cancellable-coroutine.htmlPablichjenkov
12/12/2019, 6:51 PMRuckus
12/12/2019, 6:54 PMJohn
12/12/2019, 7:00 PM