-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a simpler way to bind items in a set #384
Comments
That would be a very good addition. This DSL feels like a sufficient simplification for what feels the majority of use-cases for us to implement it. However, it is missing the ability to add in the set without defining a new binding. How about bindSet<ICache> {
add { singleton { FooCache(instance()) } } // Adds to the set WITHOUT a specific binding
bind { singleton { BarCache(instance()) } } // Adds to the set WITH a specific binding
} It is also missing an important ability provided by the original DSL: adding in the set from different modules. val di = DI {
bindSet<ICache>()
import(fooModule)
import(barModule)
}
val fooModule = DI.Module {
addInBindSet<ICache> { singleton { FooCache() } } // Adds to the set WITHOUT a specific binding
}
val barModule = DI.Module {
inBindSet<ICache> {
bind { singleton { BarCache() } } // Adds to the set WITH a specific binding
}
} Note that val fooModule = DI.Module {
inBindSet<ICache> {
add { singleton { FooCache() } }
}
} This therefore deprecates |
It is about time, but it is finally there http://kosi-libs.org/kodein/7.16/core/multi-binding.html |
In our code we create multiple caches and also put them in a set so that we can clear all caches. So I have a function that looks like this:
It seems to me that it should be possible to define a DSL to greatly simplify the creation of a binding and adding that to a set. Something like this is what I envision;
The text was updated successfully, but these errors were encountered: