Closed CLOVIS-AI closed 1 year ago
In fact there is already something for this use case. Maybe the documentation is not that easy to find. https://kosi-libs.org/kodein/7.19/core/bindings.html#_transitive_dependencies under the "tips" section.
val di = DI {
bindSingletonOf(::FooService)
// OR
bindProviderOf(::FooService)
}
This is ok for a range from 0 to 10 constructor parameters.
Thanks, that's exactly what I was searching for. Have a good day :)
Problem
Currently, we often end up with declarations like this:
This is inconvenient, because each time a parameter is added or removed, the DI module declaration fails to compile.
Proposal
Introduce helpers to generate singletons trivially for any number of arguments (per Kotlin tradition, up to 22):
This way, adding or removing arguments does not make the CI module stop compiling.