I've seen this snippet:
@Component(modules = {TestActivityModule.class})
public interface TestActivityComponent {
void inject(TestActivity activity);
}
But the inject
method is not implemented in user code (but auto-generated in Dagger-2
code).
So is the inject
a reserved name? how Dagger-2
knows to implement this method?
Ok, I got it: the name doesn't matter, it can be e.g.
squeeze
, as long as the provided type contains@Inject
fields(s)/methods(s)/constructor(s),Dagger-2
will generate the method's body:...and as long as there's a
@Provides
that returns the@Inject
ed type:Of course,
Thingie
should have@Inject
ed member or nothing will happen:That's the whole story...