ViewModelStore



Stores ViewModel instances by key.

A ViewModelStore instance must be retained across configuration changes. If an owner (typically a ViewModelStoreOwner) is destroyed and recreated due to a configuration change, the new owner must reuse the previous ViewModelStore instance.

When the owner is being destroyed permanently (i.e., it will not be recreated), it should call clear to notify all stored ViewModel instances that they are no longer needed (see ViewModel.onCleared).

Use ViewModelStoreOwner.viewModelStore to retrieve a ViewModelStore for activities and fragments.

Not stable for inheritance

This class is not intended for inheritance. It is technically open for binary compatibility with previous versions, but extending this class is unsupported.

Summary

Public constructors

Cmn

Public functions

Unit

Clears this store and notifies all stored ViewModel instances that they are no longer used.

Cmn
open String
Cmn

Public constructors

ViewModelStore

ViewModelStore()

Public functions

clear

fun clear(): Unit

Clears this store and notifies all stored ViewModel instances that they are no longer used.

After this call, the store is empty.

See also
onCleared

toString

open fun toString(): String