Skip to content

Latest commit

 

History

History
18 lines (11 loc) · 1.17 KB

README.md

File metadata and controls

18 lines (11 loc) · 1.17 KB

Dagger2

Implementation of dagger 2 with MVVM architecture, Retrofit, RxJava

Dagger 2.10 released with android support module and android compiler. I think this was a huge change for us and all android developers should switch to new dagger android injection as soon as possible.

alt text

In the old dagger activity know about the dependency injection initialize the dependency let's have a look

    ((MyApplication)getApplication())
            .getAppComponent()
            .plus(new LobbyActivityModule())
            .inject(this);

The code above makes it apparent that the activity knows quite a bit about how it’s initialized with the dependencies. This violates the core principle of dependency injection known as Inversion of Control: The client delegates the responsibility of providing its dependencies to external code (the injector). The client code does not need to know about the injecting code.

Dagger 2.10+ and its dagger.android aim to address the issue above in addition to simplifying dependency injection in Android in general.