Package 

Interface ViewModelDelegateFactory


  • 
    public interface ViewModelDelegateFactory
    
                        

    This is invoked each time a Fragment accesses a ViewModel via the Mavericks extension functions (eg fragmentViewModel, activityViewModel, existingViewModel).

    It allows global callbacks for when a view model is instantiated, with control over how the view model state should be instantiated.

    • Method Detail

      • createLazyViewModel

         abstract <S extends MavericksState, T extends Fragment, MavericksView, VM extends MavericksViewModel<S>> Lazy<VM> createLazyViewModel(T fragment, KProperty<?> viewModelProperty, KClass<VM> viewModelClass, Function0<String> keyFactory, KClass<S> stateClass, Boolean existingViewModel, Function1<MavericksStateFactory<VM, S>, VM> viewModelProvider)

        Create a Lazy ViewModel for the given Fragment.

        Parameters:
        existingViewModel - If true the view model is expected to already exist, so a new one should not need to be created.
        viewModelProvider - This function should be used to actually do the work of creating the viewmodel.