Injecting the beans

@Inject is used to inject the required dependencies. For example, let's say there are two classes—IdGenerator and Identity. IdGenerator has to be injected into the Identity class. We can use @Inject for this without having to instantiate the IdGenerator inside the Identity class.

This is shown in the following code:

class Identity {
@Inject
private lateinit var idGenerator: IdGenerator
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset