filmov
tv
#4 ViewModelFactory Tutorial -Android ViewModelFactory example-Android Dependency Injection tutorial

Показать описание
Today our Topic is ViewModelFactory. ViewModelFactory is a specially designed class which follows the Factory Design pattern and creates ViewModel classes for us.
ViewModelFactory also provides some kind of very simple and modular dependency injection without using any Dependency Framework which is useful for small and medium size project. On a side note, please do not use ViewModelFactory as dependency injection in large projects, use any framework like Dagger or CodeIn instead. So,in this tutorial we will see how to use ViewModelFactory and why particularly it is useful. If you already familiar with Factory Design pattern then it will be easy to understand. But if you not, don’t worry, I have explained the Factory Design pattern later in this tutorial with example.
I demonstrate a super easy and simple way to write your Dependency Injection Implementation which does not require Dagger 2. Using AndroidViewModel, you can write a Dependency Injection Container is a few lines of code.
Since this project uses ViewModelProvider.Factory, I also show you how I wire that up.
#AndroidViewModelFactory
#AndroidViewModelFactoryTutorial
#AndroidViewModelFactoryDependencyInjection
#AndroidAppDevelopmentTutorial
#AndroidDependencyInjection
ViewModelFactory also provides some kind of very simple and modular dependency injection without using any Dependency Framework which is useful for small and medium size project. On a side note, please do not use ViewModelFactory as dependency injection in large projects, use any framework like Dagger or CodeIn instead. So,in this tutorial we will see how to use ViewModelFactory and why particularly it is useful. If you already familiar with Factory Design pattern then it will be easy to understand. But if you not, don’t worry, I have explained the Factory Design pattern later in this tutorial with example.
I demonstrate a super easy and simple way to write your Dependency Injection Implementation which does not require Dagger 2. Using AndroidViewModel, you can write a Dependency Injection Container is a few lines of code.
Since this project uses ViewModelProvider.Factory, I also show you how I wire that up.
#AndroidViewModelFactory
#AndroidViewModelFactoryTutorial
#AndroidViewModelFactoryDependencyInjection
#AndroidAppDevelopmentTutorial
#AndroidDependencyInjection
Комментарии