What Is The Difference Between ViewModelProviders And ViewModelProvider Class?
I saw two classes with a similar name, ViewModelProviders, and ViewModelProvider. Can anyone explain what are the difference between these classes? which class actually provide the ViewModel?
ViewModelProviders(belongs to Maven artifact android.arch.lifecycle:extensions) is a class from
android.arch.lifecycle package which contains utilities methods for ViewModelStore class & returns you object of
ViewModelProvider class when you use
of() method from it.
So, you can think of as wrapper around library class for
On the other hand, ViewModelProvider(belongs to Maven artifact android.arch.lifecycle:viewmodel) is class that provides
ViewModels for a scope. So it's default
ViewModelProvider for an
Activity or a
Fragment can be obtained from
So, yes ! this is the main class that provides core logic for your
ViewModel, but you'll need to obtain it from
ViewModelProviders which returns you this class to obtain
After ViewModel version 2.2.0:
ViewModelProviders has been deprecated and we can now use
ViewModelProvider directly by creating it's new instance for getting
Something like this:
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View