Is there an easy way to call suspend functions fro...
# coroutines
m
Is there an easy way to call suspend functions from Java 7? I saw some useful APIs in kotlinx-coroutines-jdk8 but that's bit too high for Android
m
I think the easiest way is to create a non-suspending wrapper function in Kotlin, and then call that function from Java.
👆 1
g
You need some async abstraction (some promise, future etc) to expose it for Java consumer
Java 7 doesn't have any existing abstractions (except Future, which cannot be used without blocking of the thread), so you need something: guava ListanableFuture, RxJava single etc Alternatively, if you don't want add dependencies to 3rd party libraries, introduce own Promise-like abstraction and write coroutines adapter for it, or just expose this API as simple callback
591 Views