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.

Multibinding: Sets

Multibinding: Sets

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

Start my 1-month free trial

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…

Contents