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

Real-world example: Architecture components #3

From the course: Android Dependency Injection with Dagger 2 and Kotlin

Start my 1-month free trial

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…

Contents