Reputation: 681
In Dagger2 is it possible to request same class for injection from more than one component. Sample code below
@Component(modules = classA.class)
interface compA
{
void inject(MyActivity target);
}
@Component(modules = classB.class)
interface compB
{
void inject(MyActivity target);
}
If possible please explain with reason and any doc reference.
Thanks
Upvotes: 0
Views: 77
Reputation: 93561
Not at the same time. You can call either inject function you wish on it, but you can't inject it with compA then compB. You could however make a componentC that builds off of subcomponents A and B and inject it with that.
Upvotes: 1