ViewModelLazy



An implementation of Lazy used by androidx.fragment.app.viewModels and androidx.activity.viewModels.

storeProducer is a lambda that will be called during initialization, VM will be created in the scope of returned ViewModelStore.

factoryProducer is a lambda that will be called during initialization, returned ViewModelProvider.Factory will be used for creation of VM

extrasProducer is a lambda that will be called during initialization, returned HasDefaultViewModelProviderFactory will get CreationExtras used for creation of VM

Summary

Public constructors

<VM : ViewModel> ViewModelLazy(
    viewModelClass: KClass<VM>,
    storeProducer: () -> ViewModelStore,
    factoryProducer: () -> ViewModelProvider.Factory,
    extrasProducer: () -> CreationExtras
)
Cmn

Public functions

open Boolean
Cmn

Public properties

open VM
Cmn

Public constructors

ViewModelLazy

<VM : ViewModel> ViewModelLazy(
    viewModelClass: KClass<VM>,
    storeProducer: () -> ViewModelStore,
    factoryProducer: () -> ViewModelProvider.Factory,
    extrasProducer: () -> CreationExtras = { CreationExtras.Empty }
)

Public functions

isInitialized

open fun isInitialized(): Boolean

Public properties

value

open val value: VM