https://kotlinlang.org logo
Title
k

Kristian Nedrevold

03/19/2023, 7:31 PM
How do I await a completableFuture inside an effect {} block?
s

simon.vergauwen

03/19/2023, 7:33 PM
The same as you would regularly do with KotlinX Coroutines, https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-jdk8/
k

Kristian Nedrevold

03/19/2023, 7:35 PM
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

simon.vergauwen

03/19/2023, 7:37 PM
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

Kristian Nedrevold

03/19/2023, 7:38 PM
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

Kristian Nedrevold

03/20/2023, 9:10 AM
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 🙂