‫Hello, my friends.
‫Since we've created a custom Android view model that accepts a repository and application, and in all
‫cases we need to create a view model factory.
‫I will go to here to the The View model.
‫I will create a new Kotlin class.
‫I will name it as Node A View model factory.
‫And the interaction between the view and the repository is done by this view model factory because we're
‫not going to directly create an instance of note view model.
‫We need to interact with this factory.
‫So this factory inside its constructor, I need to pass a application variable.
‫It's called Application app.
‫And I need to pass a repository from the Node Repository class.
‫Val Node repository.
‫It's of type node repository.
‫And here I need to tell Android Studio that this class will act as a view model provider dot factory
‫so it will implement the factory interface and act as a factory for the view model.
‫Okay.
‫Inside these two curly braces.
‫I need to override a create function.
‫So type create here override function.
‫This is the create.
‫Method.
‫And as I told you, no need to understand all of these bunch of codes because they are like a template.
‫You can use it in all of your applications.
‫So we need only to change the return.
‫And here you put the two you need to link the ViewModel with the ViewModel factory.
‫So return a ViewModel and I pass app note repository as T.
‫So here you link the your ViewModel with the ViewModel factory.
‫And this is, this is a very important and very simple step in our application.