I'm using Koin 3.2 which has the new module includes feature. In the official docs, when discussing module linking strategies, there is this paragraph:
An important detail to observe is that you can use includes to add internal and private modules too - that gives you flexibility over what to expose in a modularized project.
That is exactly what I need, but I can't find elsewhere in the docs how to set up a "private" module that only provides dependencies for the parent module, so that those child dependencies are not available for injection. E.g.:
class SomeNonInjectableClass
class SomeInjectableClass(private val sni : SomeNonInjectableClass)
val privateModule = module {
singleOf(::SomeNonInjectableClass)
}
val publicModule = module {
includes(privateModule)
singleOf(::SomeInjectableClass)
}
In my main app I list the public module only, but automatically Koin provides all the included modules:
startKoin{
androidLogger()
androidContext(this@Main)
modules(publicModule)
}
So now a developer can do this from any activity:
val foo : SomeInjectableClass by inject() //Ok
val bar : SomeNonInjectableClass by inject() //I don't want this
I want developers to not to be able to inject the non-injectable classes from the private module. Something like Dagger 2's @NonInjectable
marker qualifiers.
Is this possible or should I resort to manually building my definitions using the classic DSL?