Does Koin provide the functionality of binding several dependencies into a collection, as Dagger does with multibindings?
Let's suppose I have this interface:
interface Initializer: (Application) -> Unit
And this interface has several implementations, for instance:
class LoggingInitializer: Initializer {
override fun invoke(p1: Application) {
Timber.plant(Timber.DebugTree())
}
}
The implementations are provided in different modules using bind
modifier:
val coreToolsModules = module {
single { LoggingInitializer() } bind Initializer::class
}
And such modules are installed in the app's Application class:
class TestApplication: Application() {
override fun onCreate() {
super.onCreate()
val startKoin = startKoin {
logger(PrintLogger())
androidContext(this@TestApplication)
modules(listOf(coreToolsModules))
}
}
}
I'd like to inject all implementations of Initializer class as a set to my Application class in order to carry out such initialization:
val initializers: Set<Initializer> by inject()
//in onCreate()
initializers.forEach { it.invoke(this) }