ViewModelLifecycle
Author
skydoves (Jaewoong Eum)
An implementation of Lifecycle, which follows the ViewModel's lifecycle. ViewModelLifecycle handles multiple LifecycleObserver and ViewModelLifecycleObserver to track ViewModel's lifecycle. ViewModelLifecycle belongs to ViewModelLifecycleOwner, you can get this directly from the ViewModelLifecycleOwner.
ViewModelLifecycleOwner only handles Lifecycle.Event.ON_START and Lifecycle.Event.ON_DESTROY, which are the same as the ViewModelState.INITIALIZED and ViewModelState.CLEARED.
Constructors
Functions
Adds a LifecycleObserver that will be notified when the ViewModelLifecycle changes state.
Adds a ViewModelLifecycleObserver that will be notified when the ViewModelLifecycle changes state.
Returns the current state of the ViewModel lifecycle. ViewModelLifecycle has only two lifecycle states; Lifecycle.Event.ON_START and Lifecycle.Event.ON_DESTROY, so make sure don't depend other lifecycle states.
Returns the current count of the observers.
Remove a LifecycleObserver from the internal observers list.
Properties
Check the current ViewModelState is cleared or not.