You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Component - An interface contain methods that specify to Dagger where to inject the dependencies. It is added on top of the class and includes modules providing the dependencies.
@Inject - Used to request for dependency in classes which requires to use them.
Creating DaggerComponent
Once the module and Component has been created, build the app and dagger will automatically generate DaggerComponent that you will use to initialize you component.
For Easier implementation, create a class extending Application class and define your component which you initialize on its onCreate
Create a public method to provide the component
You can also create a public static method to give you the instance of the class such that you will not have to create its object from your activity but instead call it directly
On your Activity's oncreate, call the component and access it method specifying injection target and give it the activity context
use @Inject to request for your dependencies provided by the module