Join G. Blake Meike for an in-depth discussion in this video Using the exercise files, part of Android Dependency Injection with Dagger 2 and Kotlin.
- [Instructor] The exercise files for this course were organized so that it's easy to compare the code from the various lessons side by side. The code for each section is in its own package. For instance, in the section on Essentials, there is a presenter, shown here, and later on, when we review components, there's another version of the presenter that's over here. Although this organization is great for side by side comparison, it means that several packages contain nearly identical code.
Obviously no real application would ever be coded this way. In addition, there's an alligator in this swamp. Because so much of what Dagger does is based on type inference, even a minor error in an import statement can result in code that will never compile under any condition. If you're going to experiment with Dagger, and I definitely recommend you do that, it would be much safer to start with a fresh project, copying only the specific parts of code with which you want to experiment. Usually that will just mean copying the main activity, here, and the code from one of the sub-packages of net.callmeike.android.daggerwithkotlin, so one of these packages.
- Dagger basics
- Method and field injection
- Lazy and provider injection
- Dagger annotations: @Module, @Binds, @Provides, and @Named
- Components and subcomponents
- Singletons and custom scope