Hey o/ I'm trying to implement the coroutines libr...
# coroutines
j
Hey o/ I'm trying to implement the coroutines library on a JVM-based gaming platform. I was wondering if there is a possibilty to implement the
Dispatchers.Main
dispatcher (other than using the
ServiceLoader
). This would be useful, because a lot of the data needs to be updated from the main game loop. I'm aware that I could create my own dispatcher and I have done that. I just think that it would be more ideomatic if I could use the
Dispatchers.Main
Dispatcher.
a
I think there is a
setMainDispatcher
function or similar. I think it is often used in unit tests.
But what's the problem with the service loader?
e
setMainDispatcher is only in the kotlinx-coroutines-test package, changing what its service loader returns
but yeah, why not service loader?
j
I was just wondering if there was an officially supported way. The
MainDispatcherFactory
is marked as
InternalCoroutinesApi
.
e
Not public at the moment, but your use-case is quite compelling to stabilize this SPI. Please, file an issue to https://github.com/Kotlin/kotlinx.coroutines/issues