From the course: Android Dependency Injection with Dagger 2 and Kotlin
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Real-world example: Architecture components solved
From the course: Android Dependency Injection with Dagger 2 and Kotlin
Real-world example: Architecture components solved
- [Instructor] In previous videos we worked a complex example using Dagger in a real world application, and it didn't quite work, but I promise that we could fix it. The reason it didn't work is that we couldn't yet tell Dagger to create a key of type class out ViewModel. We now know how to create more complex key types using the @MapKey annotation. In the last video, we used @MapKey to create a new key annotation, that created a mapkey from an enum. In this video, we'll see how to create a map with a more complex key. Again note, that the complete documentation for the syntax for annotation classes is available at kotlinlang.org. I'm not going to write all this code out, it's very similar to code we've seen before. What I do want to point out, is that the @MapKey annotation, when applied to an annotation class with multiple parameters, must have it's unwrap value parameter set false. The MapKey annotation parameter unwrap value has to be set false. This creates a new annotation…
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
-
-
-
-
-
(Locked)
When Dagger can't figure it out: @Modules and @Binds5m 6s
-
(Locked)
When it's complicated: @Provides4m 49s
-
(Locked)
When types are not enough: @Named3m 33s
-
(Locked)
Multibinding: Sets4m 42s
-
(Locked)
Multibinding: Maps with simple keys4m 15s
-
(Locked)
Real-world example: Architecture components #14m 29s
-
(Locked)
Real-world example: Architecture components #23m 19s
-
(Locked)
Real-world example: Architecture components #31m 40s
-
(Locked)
Multibinding: Maps with complex keys4m 53s
-
(Locked)
Real-world example: Architecture components solved3m 25s
-
(Locked)
-
-
-