This is what my code looks like
# dagger
k
This is what my code looks like
g
And where do you inject interactorLookup property?
also not really sure why do you use property injection instead of constructor injection
k
I get error at
lateinit var interactorLookup
. I’m aware I’m doing the property injection for now, but I’m not sure what’s wrong here! (Atleast I didn’t get the missing part yet)
g
But you have this property, but I don’t see where do you inject it
it should be some
inject(this)
in LookupViewPresenter
I see in your snippet inject fro Activity, but not for LookupViewPresenter
Property will not be injected automatically, only explicitly
and I still don’t understand why you cannot use constructor injection:
Copy code
class LookupViewPresenter @Inject constructor(
   mView: LookupViewContract.View, 
   val interactorLookup: LookupInteractorImpl
)
k
But let’s say I have multiple Interactors in my Presenter. Will it be nice to use constructor injection?
g
Use constructor injections is always nice, there is no cases when usage of field/method injection would be better than use constructor
if you have multiple Interactors of the same type just use qualifiers to distinguish between them
k
Sorry for the later reply, I was held up with something else. So I have 6 different types of Interactors in my presenter! You suggest me to do constructor injection for all?
g
Hmm, not 100% sure what you mean by “do constructor injection for all”
My point that if you can use constuctor injection (aka this class is not instantiated by Android Framework) you should use constructor injection and keep field injection only for cases when you have no another choice (like Android Framework components)
👍 1
k
Yeah got it. I have done it via constructor injection
Thanks for your help.. 👍