Dagger, Injecting custom objects (Interface implementation)
It is very connivent to use any DI framework when all the objects required are available in application. For example, I have two classes Logger, Service and class Middleware is dependent on these classes.
class Logger()
class Service()
//this class requires Logger & Service object
class Middleware(private val logger:Logger. private val service:Service)
// middleware object
val middleware = Middleware(Logger(),Service())
Dagger can build objects of Logger and Service classes by indicating @Inject annotation to all three classes
internal class Logger @Inject constructor()
internal class Service @Inject constructor()
//this class requires Logger & Service object
internal class Middleware @Inject constructor(private val logger:Logger.