Package 

Interface MavericksViewModelFactory


  • 
    public interface MavericksViewModelFactory<VM extends MavericksViewModel<S>, S extends MavericksState>
    
                        

    Implement this on your ViewModel's companion object for hooks into state creation and ViewModel creation. For example, if you need access to the fragment or activity owner for dependency injection.

    • Method Summary

      Modifier and Type Method Description
      VM create(ViewModelContext viewModelContext, S state)
      S initialState(ViewModelContext viewModelContext) The initial state for the ViewModel.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

         VM create(ViewModelContext viewModelContext, S state)
        Parameters:
        viewModelContext - ViewModelContext which contains the ViewModel owner and arguments.
        state - The initial state to pass to the ViewModel.
      • initialState

         S initialState(ViewModelContext viewModelContext)

        The initial state for the ViewModel. Override this if the initial state requires information from arguments, or the ViewModel owner. This function will take precedence over any secondary constructors defined in the state class, S.

        The return value of this function will be transformed with any PersistState values before being used in create.