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.
Multibinding: Sets
From the course: Android Dependency Injection with Dagger 2 and Kotlin
Multibinding: Sets
- [Instructor] In this section we've seen how Dagger modules can be used to give Dagger additional information that it needs. In the next several videos, I will show you how modules can be used for something else entirely, how they can be used to put objects into collections. Generically, this subject is called multibinding. Dagger can put objects into sets and maps. Let's start by looking at how Dagger puts objects into sets. There are a number of reasons that you might want Dagger to build a set. As an extremely simple example, suppose that your application is a string decorator. A user types in a string and your app decorates it in several different ways. One way that you might do this is with a set of decorator objects, each of which applies some decoration to the string. A Processor, in this application, iterates over the decorators in the past set applying each one to the input string. It returns the set of decorated strings. Let's teach Dagger to build the set of decorators on…
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)
-
-
-