Hi
I posted some questions on #koin-dev but I just found out about this channel so will post here as well, probably more appropriate:
When overriding a module like in the documentation example:
val myModuleA = module {
single<Service> { ServiceImp() }
}
val myModuleB = module {
single<Service> { TestServiceImp() }
}
// Will throw an BeanOverrideException
startKoin {
modules(myModuleA,myModuleB)
}
we see that koin create ServiceImp instance but even if we override it - any good way to avoid it ?
It is a ktor-koin project and we have some scheduler in the ServiceImp init that we don’t want to start at all when just running the tests
Thanks
k
kevindmoore
08/03/2021, 8:08 PM
I thought there was an override parameter you could use
j
Jgafner
08/04/2021, 8:44 AM
I ll add a bit more details to my question:
We are using ktor and we install koin in the ktor application
Copy code
fun Application.main() {
install(Koin) {
modules(modules)
}
}
now in the module we have various Services we want koin to inject.
In the test we want to override the those service and skip their loading since some of them are triggering async tasks at their init block.
a
arnaud.giuliani
08/13/2021, 8:00 AM
2 options then, override definitions with dedicated module for test else use