Closed
Description
http://stackoverflow.com/questions/32341839/multiple-independent-component-injection
I've created an issue on stack overflow but i thought this repo would be more appropriate.
As you can see, why would such a configuration throw a compilation error? All the injections are satisfied by components individually. Yet it is expecting the first component to inject into the variable (B b).
Activity
amatkivskiy commentedon Sep 14, 2015
+1. This feature will help to decouple components by their responsibilities without need to create separate component (to merge that components into one) to inject multiple variables from different components.
netdpb commentedon Dec 10, 2015
Dagger does expect to satisfy all injected dependencies of a type with one component (which may use subcomponents and/or component dependencies). JSR-330 requires implementations to inject all
@Inject
-annotated members.Guice has an
OptionalBinder
feature that lets you injectOptional<Foo>
, which is absent if there is no binding forFoo
. If all your injected fields used that, you might get something like what you want.Dagger does not have an analogous feature, but we're considering it.
I'm closing this bug, but feel free to continue the discussion on Stack Overflow.