Joel Denke
05/23/2023, 7:12 AMactual val coroutineDispatchersModule = module {
single(named("ioDispatcher")) { <http://Dispatchers.IO|Dispatchers.IO> }
factory(named("ioScope")) { CoroutineScope(get(named("ioDispatcher"))) }
}
To inject coroutine scope each time need it, or only using dispatcher/context if need it.
And then for compuation and main stuff as well.
In iOS seems like there is some weird wrappers can use in darwin C wrappers, but not sure how to combine it with Coroutines to be sure not freezing issues or such.actual val coroutineDispatchersModule = module {
single(named("ioDispatcher")) { IosMainDispatcher }
factory(named("ioScope")) { CoroutineScope(get(named("ioDispatcher"))) }
}
object IosMainDispatcher : CoroutineDispatcher() {
override fun dispatch(context: CoroutineContext, block: Runnable) {
dispatch_async(dispatch_get_main_queue()) { block.run() }
}
}