Dagger
Dagger offers a comprehensive way to organize your application's dependencies. It has the advantage of being adopted first on Android by the developer community before Kotlin was introduced. This is one of the reasons that many Android applications use Dagger as their DI framework. Another advantage the framework holds is for Android projects written in Java, because the library is developed in the same language. The framework was initially developed by Square (Dagger 1) and later transitioned to Google (Dagger 2). We will cover Dagger 2 in this chapter and describe its benefits. Some of the key functionalities Dagger 2 provides are the following:
- Injection
- Dependencies grouped in modules
- Components used to generate dependency graphs
- Qualifiers
- Scopes
- Subcomponents
Annotations are the key elements when dealing with Dagger, because it generates the code required to perform the DI through an annotation processor. The main annotations can...