Presenter injection with Dagger 2

后端 未结 2 542
情深已故
情深已故 2021-02-08 05:04

I just started using Dagger 2 and I found online thousands guides each one with a different implementation and I\'m a bit confused now. So basically this is what I wrote at the

2条回答
  •  无人共我
    2021-02-08 05:43

    You do not have to provide Presenter if @Inject annotation is used in the constructor. @Inject annotation used in the constructor of the class makes that class a part of dependencies graph. So, it also can be injected when needed.

    On the other hand, if you add @Inject annotation to fields, but not to constructors, you have to provide that class.

提交回复
热议问题