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
Multibinding support? #515
Comments
The manual workaround is to have
but as you see, this kind of defeats the modularity of Assemblies, as me as a Feature1 developer need to plug the instance at N places where N is the number of apps in the project; which is doable but annoying and should be a DI library feature |
What would you want to do with this |
It's mostly used for dependency inversion when modularizing, and you wish for Assembly to be packaged with the module. For example
The whole point of the inversion is to enable codebases with multiple apps, where those apps vary in features. Say App A will only include "dynatrace tracker", and App B will include "dynatrace tracker" and "firebase tracker". So, from this you can see that I cannot just have constructor with all the dependencies listed as one normally would
Therefore it needs to be turned into an array and pushed to DI assemblies. However this means I need to have AppAAnalyticsAssembly and AppBAnalyticsAssembly, which is redundant and not really nice; hence the multibinding feature of Dagger |
Was also looking into how this feature might exist in Swinject. Agreed that a |
So I recently learned that this functionality is possible with existing Swinject by using a custom Behavior on the container. This is actually one of the examples used in the initial Behaviors proposal (it is called "Instance Aggregation"). There is also another example of a very similar approach "SwinjectResolveManyBehaviour". |
@bradfol what did you end up with please? I'm not really keen on the |
Coming from android / Dagger side of the world, the thing I'm missing to facilitate a highly modular codebase is multibinding.
Essential, what it is, is that the implementation is registered as its protocol type - the usual stuff.
However, I'm then able to be pull out (inject) all these protocol-implementing instances as a set or array, i.e.
Set<SomePlugin>
This allows for a plugin architecture which is a necessity in a multi-app modular shared codebase
The text was updated successfully, but these errors were encountered: