Posts

Showing posts with the label Dagger

Kotlin Dependency Injection (Dagger)

Dagger provide dependency injection using the annotations.             1) @Inject             2) @Module             3) @Provides             4) @Component 1) Inject  defines which object you want to inject to your view. 2) Modules are responsible to provide appropriate object to the injected fields. 3) Provides returns the object from the method define in the module class. 4) Component is the bridge between injected object and Object class(Module). Now that we understand a bit, we can go forward with dependency injection exploration using one example. First you have to add the below gradle to your project :- Dagger implementation 'com.google.dagger:dagger:2.13' kapt 'com.google.dagger:dagger-compiler:2.13' Apply plugin   ...