I am wondering if we can implement a `suspend` met...
# coroutines
t
I am wondering if we can implement a
suspend
method in Java class. What's the correct way to do it? SO Thread: https://stackoverflow.com/questions/68032757/how-can-i-implement-kotlin-suspend-method-in-a-java-class
d
You really shouldn't, to be honest. If you want Java interop you need to design your APi in a Java-compatible way,
suspend
functions aren't. Provide a
CompletableFuture
based version for Java.
✔️ 3
c
Note that you won't be able to call suspend functions easily from Java, even inside a suspend function: you need to pass the correct parameter to the Continuation, and handle the callbacks yourself. It's fairly complicated