ViewModelPropertyDelegate

This can be used to store a property of a fragment in a ViewModelStore. The property will be encapsulated in a ViewModel and stored, so that it can be retrieved upon re-creation of a fragment.

Parameters

P

The type of the property being delegated.

key

Unique identifier for P.

Constructors

Link copied to clipboard
constructor(key: String)

Functions

Link copied to clipboard
open operator override fun getValue(thisRef: Any?, property: KProperty<*>): P
Link copied to clipboard
fun initialize(viewModelStoreOwner: ViewModelStoreOwner)

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

Link copied to clipboard
fun setInitialValue(property: P)

Set the initial value of the property.