Skip to content

Dagger ‐ Some theory about component relationship

Devrath edited this page Oct 8, 2023 · 1 revision

How Consumer gets object references in Dagger

Untitled drawio

How Consumer gets object references in Dagger

Untitled drawio (1)

  • In a dagger there can be multiple components and the consumer might have to get the objects from all the components
  • So whatever the requirements of the consumer, The consumer requests from corresponding components.
  • The component finds the object(if exists) and provides it from @Inject annotated constructor or from a @Module.
  • The component could be defined at an application level, activity level, or fragment level.

Relationship between components

Untitled drawio (2)

  • Now the consumer can request in such a way that, Say consumer requests some object references from a fragment component, and the fragment component can request some object references from an application component.
  • Thus there can be a relationship between the components and thus a dependency.
  • Now finally the fragment component will be the one that gives the references to the consumer.
Clone this wiki locally