ViewModelLazy

public final class ViewModelLazy<VM extends ViewModel>


An implementation of Lazy used by androidx.fragment.app.Fragment.viewModels and androidx.activity.ComponentActivity.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

Summary

Public fields

@NonNull VM

Public constructors

<VM extends ViewModel> ViewModelLazy(
    KClass<VM> viewModelClass,
    Function0<ViewModelStore> storeProducer,
    Function0<ViewModelProvider.Factory> factoryProducer
)

Public methods

boolean

Public fields

value

public @NonNull VM value

Public constructors

ViewModelLazy

public final <VM extends ViewModel> ViewModelLazy(
    KClass<VM> viewModelClass,
    Function0<ViewModelStore> storeProducer,
    Function0<ViewModelProvider.Factory> factoryProducer
)

Public methods

isInitialized

public boolean isInitialized()