Hello if my presenter is written in java and my datasource is in kotlin and I have used coroutines, how do I connect them? Do I have to use the
suspendCancelableCoroutine{..}
? Then do i need the
launch{}
somewhere? Or from the java class I call the method of my presenter and that's it? I can avoid the launch?
d
diesieben07
02/16/2021, 4:16 PM
Java cannot interact with suspending functions in a meaningful way. You have to expose any suspending functions that you want to use from Java in a way that Java can consume - i.e. as a
CompletableFuture
or something similar.
E.g.:
Copy code
suspend fun doSomething(): String = TODO()
fun doSomethingFutureAsync(): CompletableFuture<String> = future { doSomething() }
I mean if my presenter is in Java and I have a datasource that has de suspendCancellableCOroutine this method has to be suspend right? otherwise it won't work