https://kotlinlang.org logo
Title
t

tw

10/17/2018, 1:53 PM
I had a similar question I’ve been meaning to ask - I’m working with a third party library that has a blocking call - it’s non-cpu intensive (just a really basic subscription) - but I am unsure of the best way to allow many of these subscriptions to run at the same time with co-routines
e

enleur

10/17/2018, 1:55 PM
use
<http://Dispatchers.IO|Dispatchers.IO>
, it was made for this purpose
withContext(<http://Dispatchers.IO|Dispatchers.IO>){
    Thread.sleep(1000)
    ... or another blocking code
}
d

dave08

10/18/2018, 3:10 AM
If it's rx, there's Rx converters in the rx2 lib in kotlinx.coroutines, but you still need the right dispatcher as mentioned.