ViewModelDelegate

class ViewModelDelegate<VM : ViewModel>(key: String) : ReadOnlyProperty<Any?, VM>

Class to be used as a delegate to a ViewModel which can be stored and retrieved in a ViewModelStore.

Parameters

VM

The type of the view model being delegated.

key

Unique identifier for this ViewModel.

Constructors

Link copied to clipboard
fun ViewModelDelegate(key: String)

Functions

Link copied to clipboard
open operator override fun getValue(thisRef: Any?, property: KProperty<*>): VM
Link copied to clipboard
fun <O : ViewModelStoreOwner, HasDefaultViewModelProviderFactory> initialize(    viewModelStoreOwner: O,     viewModelClass: KClass<VM>,     factoryAvailable: Boolean)

Initialize the delegated view model by either restoring or storing it in the ViewModelStore of the ViewModelStoreOwner.