Colton Idle
07/31/2020, 6:59 AM@Provides
)wasyl
07/31/2020, 8:42 AMColton Idle
07/31/2020, 8:54 AMwasyl
07/31/2020, 9:04 AM@Provides
to inject something? Aren’t @Provides
method used to provide dependencies in modules?Colton Idle
07/31/2020, 9:07 AMPersonally I think that field injection scales rather badly, so I prefer to put in a provision method for every dependency I need, and then pass my component around. So it looks like this.@wasyl I'm still learning so I also don't really know exactly what I'm talking about, but a @Provides method goes into a module, and then is referenced in a component so that a component can use it when needed.
wasyl
07/31/2020, 9:09 AM@Inject lateinit var injectedProperty: SomeClass
vs 2)
fun onCreate() {
this.property = Injector.get().someClass()
?ritesh
07/31/2020, 10:16 AMtrevjones
07/31/2020, 3:38 PM@Inject
over the component being passed around every time. by using component methods you lose the clear list at the top of a file of “this is what I need to work” and you also couple yourself to the component interface which has an intrinsic implementation so it can cause you to lose a good inversion of control (unless it is an interface that itself isn’t a component, or it is a subcomponent for which you have multiple implementations generated, ie one for scenario a, one for b and one for test, etc…)
I expect long term maintenance is likely going to be lower with field injection as well due to the compiler doing more of that upkeep for you.Colton Idle
08/01/2020, 1:47 AMtrevjones
08/01/2020, 2:18 AM@Contrib
to cut down the code you have to write and it is actually a really great system to work with. so we really only needed the @Contrib
+ processor + AndroidInjector<T>
and really it could be PlatformInjector<T>
at that point. nothing android specific is left.gildor
08/01/2020, 2:52 AM