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.
Real-world example: Architecture components #3
From the course: Android Dependency Injection with Dagger 2 and Kotlin
Real-world example: Architecture components #3
- [Instructor] In the last videos, we've worked on a fairly complex real world example using Google's architecture components and Dagger. Question is, does it work? Before we try it, let's review what we've done. Dagger knows, first of all, how to create a ViewModel1. ViewModel1 had no dependencies. We gave it an at sign inject constructor. Next Dagger knows that a ViewModel1 is a ViewModel. We used an at sign bind method in the activity module to do that. Dagger also knows how to create a provider for a ViewModel1. That's Dagger magic. Dagger also knows how to build a map of class to provider of ViewModel. This is the same at sign bind method in the activity module. Furthermore, Dagger knows how to create a ViewModelFactory. This is the at sign inject constructor with a dependency on the map that we just created. Finally, Dagger knows how to inject the ViewModelFactory into the activity. So Bob's your uncle! This might just work. The build failed. Can you guess why? The reason it…
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.
Contents
-
-
-
-
-
When Dagger can't figure it out: @Modules and @Binds5m 6s
-
When it's complicated: @Provides4m 49s
-
When types are not enough: @Named3m 33s
-
Multibinding: Sets4m 42s
-
Multibinding: Maps with simple keys4m 15s
-
Real-world example: Architecture components #14m 29s
-
Real-world example: Architecture components #23m 19s
-
Real-world example: Architecture components #31m 40s
-
Multibinding: Maps with complex keys4m 53s
-
Real-world example: Architecture components solved3m 25s
-
-
-
-