Trying to invoke a coroutine from Java, for some l...
# coroutines
g
Trying to invoke a coroutine from Java, for some legacy code. This doesn't start it so far, do I miss something?
Copy code
CoroutineScope scope = ViewModelKt.getViewModelScope(this);
        BuildersKt.launch(scope, scope.getCoroutineContext(), CoroutineStart.DEFAULT,
                (_scope, continuation) -> signUp.invoke(params, continuation)
        );
z
The simplest way to do that is just write yourself a helper function in kotlin to provide a java-friendly API. But if that's not possible, I think your problem might be that you need to return
COROUTINE_SUSPENDED
from your lambda to indicate that the function didn't finish. But I think you also then need to check the return value of your signup function to either return directly or return that constant. It would be much better to just write a helper in kotlin.
🙏 1
1
g
I see, that was my backup plan, yes. Interesting details, thank you! 👍