1

I'm using both in my app. Kotlin Coroutines are used for single interactions, such as a DB or an API call. But also I'm using RxJava Flowable to observe sensor events.

Kotlin Coroutines has dispatches, and RxJava has shedulers. The idea of them is to provide maximally efficient thread pools, which size depends on hardware configuration.

So if I use both simultaneously, I can have, for example, 8 running threads, 4 in Dispatchers.Default and 4 in Shedulers.computation, instead of 4 threads.

So my question is

Is there a way use Kotlin Dispatchers as RxJava shedulers or vise versa?

Or I should define my own executors, and build dispatchers and shedulers from them?

1 Answer 1

3

You can use kotlinx-coroutines-rx2 extension library (https://github.com/Kotlin/kotlinx.coroutines/tree/master/reactive/kotlinx-coroutines-rx2) ....and in particular Scheduler.asCoroutineDispatcher

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.