create

open fun create(viewModelContext: ViewModelContext, state: S): VM?

Return

The ViewModel. If you return null the ViewModel must have a single argument constructor only taking the initial state.

Parameters

viewModelContext

ViewModelContext which contains the ViewModel owner and arguments.

state

The initial state to pass to the ViewModel. In a new process, state will have all PersistState annotated members restored, therefore you should never create a custom state in this method. To customize the initial state, override initialState.