‫Hello, my friends.
‫In the previous video, we have created a project that make a dependency injection using dagger and
‫we have talked about the mobile component interface and the other class.
‫Now we are going to talk about the modules and that's why we are going to use the modules in there.
‫We have created our our project without using the modules.
‫We use constructor injection here at inject with empty.
‫Come with empty with with empty constructors.
‫Okay.
‫So we use constructor injection when you own the classes and that constructor when you create these
‫classes by your own.
‫You can put at inject annotation.
‫But what about classes of third party libraries where you you are not owning your or these classes or
‫constructors.
‫So for example, if you added the retrofit library, you don't own the retrofit classes or constructors,
‫so you can't go and put at the inject annotation inside the classes or built in classes of retrofit.
‫Okay.
‫So like retrofit we use it's, it's calls and it's own classes, but we don't use the constructors and
‫we cannot add that at and inject annotation inside these classes.
‫We use only the builder in the retrofit.
‫So retrofit allows you only to use the some methods and you are not able to access all of these classes
‫and that that that inject method.
‫And for example in this video we are going to suppose that we don't own that battery class.
‫Okay.
‫So we have imported we are going to use the battery, but we are not going to add that inject animation
‫inside that battery constructor.
‫So suppose it suppose that the battery class, we don't own it, we don't have the it's code, we don't
‫able to access its constructor for that.
‫We create a parallel class called Battery Module and we annotate it by module.
‫And here the class we make an instance of the target class, which is the battery and provide the battery
‫method.
‫This is the returning type of the battery and return a new battery.
‫Okay.
‫So you see guys here, we annotate it by provides.
‫This is telling that that this class is not the original class.
‫This is just a module that allows us to to make and to provide the had the battery without using its
‫constructor.
‫So using the modules, we are going to link it with the component.
‫So the component, as we told you, it's like a bridge between the dagger and your codes and classes.
‫So here we need to specify the modules like battery, the module class.
‫So on telling the components that, hey, I'm using a module called battery module.
‫Now let's turn on our application and see.
‫And here we go.
‫It's the same.
‫So our application is still working.
‫Fine.
‫Bye.
‫Not injecting the constructor of the battery.
‫We are using the module here, which is part of a parallel class that allows us to to use the provides
‫annotation which provides in new instance of the battery and we have added the module in the component.
‫So what are the steps to use the models at one, create a modal class for the same or refer to this
‫that targeted class which is in this case this example was the battery to add the models modules in
‫that component interface here.
‫And and that provides method.
‫The third step is adding the provides method and which is the provide annotation.
‫Okay.
‫In the.
‫Okay.
‫This is the very simple use of the model inside Decker.