Hi, how should I "await" for a standard Java Futur...
# coroutines
v
Hi, how should I "await" for a standard Java Future inside a suspending function?
e
Using
.await()
assuming your future is in fact a CompletableFuture.
v
I'm using ApiFuture from Google API, which is a standard java.util.concurrent.Future with a addListener method. There is some utility in coroutines to use this addListener and avoid "callback hell"?
e
If it implements Guava ListenableFuture then you can use ready implementation of
.await()
from
kotlinx-coroutines-guava
module, if not, then you can copy-and-paste await extension from its source here https://github.com/Kotlin/kotlinx.coroutines/blob/master/integration/kotlinx-coroutines-guava/src/ListenableFuture.kt
v
Sure, thanks