From the course: Android Dependency Injection with Dagger 2 and Kotlin
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Introducing Dagger
From the course: Android Dependency Injection with Dagger 2 and Kotlin
Introducing Dagger
- [Instructor] Now that we've be introduced to Dagger's two essential annotations, @Inject and @Component, and understand what they do. We can rewrite the dependency injection code example we saw earlier, but this time, using Dagger. In an earlier video, we stepped through the process of building factories that created the objects we needed. With Dagger, we don't have to think about factories at all. We focus on the objects themselves. The @Inject annotation identifies the constructor used to create a presenter object. It also declares the presenter's dependencies. That is the client is argument to the constructor. So, we add an @Inject annotation to the constructor. I had to use an Android Studio Intention to import the @Inject definition. I'm going to use a keyboard shortcut here to import the definition for Inject. The Inject annotation identifies the constructor used to create a presenter object. It also declares the presenter's dependencies, the client that is the argument to the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.