Share ViewModels EVERYWHERE !
Vita is a light and simple library that helps you to share ViewModel between fragments and even activities! Also you can create ViewModels that are available all over the application! Cool, right!?
As we know we need a LifeCycleOwner (e.g Fragment or FragmentActivity) to create ViewModels, when the owner is at the end of its lifecycle the ViewModel will be cleared as well, Sometimes you need to share the ViewModel between multiple owners, By default we can only share ViewModel of an activity between its fragments for now, nothing more...
What Vita does:
- Creates ViewModels with Single Owner: This is the default ViewModel behavior that already has, The ViewModels created in this way are only available to the owner.