What is ViewModel factory in Android?

What is ViewModel factory in Android?
Answer
Factory is responsible to create your instance of ViewModel. If your ViewModel have dependencies and you want to test your ViewModel then you should create your own ViewModelProvider. Factory and passed dependency through ViewModel constructor and give value to the ViewModelProvider.
 

Tìm kiếm

Back
Top