jshvarts / ConductorMVP

Multi-project Clean Architecture MVP app in Kotlin using Conductor, Room, RxJava 2, Dagger 2 with custom scopes
Apache License 2.0
194 stars 30 forks source link

Dependecy Injection with Dagger through Android Injector #2

Closed JairAviles closed 6 years ago

JairAviles commented 6 years ago

According to your own article, regarding the new Dagger Android Injection and the external references, the purpose of these changes within the API is to ensure the following Dependency Injection principle

"A class shouldn’t know anything about how it is injected."

Having said that, is it possible to apply Dependency injection through Android Injector within this Clean Architecture? Which are the limits or disadvantages of it and why do you keep "the old way"?

jshvarts commented 6 years ago

Good question. With Conductor I did not need to inject to Android components such as Activities or Fragments. The new Dagger Android injector specifically benefits those but with this app design (only Controllers getting injections) I don’t think I could even use it.

JairAviles commented 6 years ago

Thank you. I have another doubt. Actually, I am working on a project which has the mobile module and the wear module. We are aiming to develop an Android application with a Clean architecture that could have 2 presentations (wear & mobile) that reuse the same domain and data classes. Do you think is it possible to approach our goals with your architecture? What could you suggest me? I find it very compelling, by the way.

jshvarts commented 6 years ago

Sure it's possible--that's how I would do it as well. Your presentation module would become something like "mobile" and a new module "wear" would have to be added. You could have "tv", etc added too later on.