How do I await a completableFuture inside an effec...
# arrow
k
How do I await a completableFuture inside an effect {} block?
s
The same as you would regularly do with KotlinX Coroutines, https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-jdk8/
k
I think I might be misunderstanding something then, using kotlinx-coroutines-jdk8 with the .await() extension gives me a type F!. How do I actually work with this? I was trying to achieve something similar as the awaitFirst() in the coroutines reactive streams API
s
F!
? 🤔 This should give you simply
A
, https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-jdk8/kotlinx.coroutines.future/await.html. It might return a platform type
!
which means that Kotlin didn't find
@NonNull
or
@Nullable
and it's up to you to check the Java API and deal with potential
null
coming from Java.
k
hmmm, maybe it's intellij then
I will try actually building it
Was just me getting my types wrong 🤐
If so I believe there is an extension function somewhere in the coroutines lib to convert between them
k
Yeah, there's a function in the coroutines-jdk8 module that has transformers. I had just messed up some generic types so everything was a bit wonky. Got it working now 🙂