InsertKoinIO / koin

Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform
https://insert-koin.io
Apache License 2.0
8.98k stars 710 forks source link

[koin-core-coroutines] Pass a custom Dispatcher to the Koin coroutines engine #1754

Closed cpaleop closed 7 months ago

cpaleop commented 8 months ago

Is your feature request related to a problem? Please describe. The current implementations of KoinPlatformCoroutinesTools return a hardcoded value of CoroutineDispatcher with no option to either modify this value or bypass it and use a custom one.

Describe the solution you'd like To be able to define the CoroutineDispatcher Koin will use when using the Koin coroutines engine. The API for this could be something like:

startKoin {
    dispatcher(Dispatchers.Default)
}

// or

startKoin {
    lazyModules(dispatcher = Dispatchers.Default, listOfLazyModules)
}

If not defined, then the dispatcher from KoinPlatformCoroutinesTools implementations can be used as default.

Describe alternatives you've considered None.

Target Koin project core

arnaudgiuliani commented 8 months ago

Yes, good catch 👍

arnaudgiuliani commented 7 months ago

Let's see for 3.5.4-rc-1 build. Will be soon available