MavericksViewModelFactory

interface MavericksViewModelFactory<VM : MavericksViewModel<S>, S : 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.

Functions

create
Link copied to clipboard
open fun create(viewModelContext: ViewModelContext, state: S): VM?
initialState
Link copied to clipboard
open fun initialState(viewModelContext: ViewModelContext): S?

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.