Vita

Additional

Language
Kotlin
Version
0.1.0 (Aug 21, 2019)
Created
Aug 20, 2019
Updated
Aug 22, 2019
Owner
Farshad (FarshadTahmasbi)
Contributor
Farshad (FarshadTahmasbi)
1
Activity
Badge
Generate
Download
Source code
APK file

Promotion

Vita

An extension for android ViewModel

Vita is a light and simple library that helps you to share ViewModel between fragments and activities, even you can create ViewModels in application scope

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.

  • Creates ViewModels with

    • Creates ViewModels with

      No Owner: The ViewModels have no owner, they are available in the application scope and stay alive until the user closes the application

    Multiple Owners: The ViewModels are shared between multiple owners and stay alive while at least one owner is alive