I had a similar question I’ve been meaning to ask ...
# coroutines
t
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
use
<http://Dispatchers.IO|Dispatchers.IO>
, it was made for this purpose
Copy code
withContext(<http://Dispatchers.IO|Dispatchers.IO>){
    Thread.sleep(1000)
    ... or another blocking code
}
d
If it's rx, there's Rx converters in the rx2 lib in kotlinx.coroutines, but you still need the right dispatcher as mentioned.