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.
@Component dependencies
From the course: Android Dependency Injection with Dagger 2 and Kotlin
@Component dependencies
- [Instructor] In the last video, I showed how to extend the component's builder, so that you can pass parameters to it. What happens if those parameters are other components? Whoa, you say, that's crazy. Well, it is a little mind-bending. It makes sense though. We've already seen our components get objects from modules, so why not from another factory? Also, remember, a component is just an object factory. No good architect would suggest a single factory for all the objects needed in her application. That would just be interface pollution and bad separation of concerns. Finally, it just makes a lot of sense to keep the code for an object factory near the objects it provides. It's just easier to work on. Component dependencies are actually pretty straightforward. There are just a couple of rules. First, declare component dependencies in the dependencies parameter for the @component annotation. It's a list similar to the list of module dependencies used as the module parameter. Unlike…
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.