createViewModel

protected open fun createViewModel(modelClass: Class<out ViewModel>): ViewModel

Return a ViewModel.

If you want to initialization a ViewModel with parameters,just do like this:

override fun createViewModel(modelClass: Class<out ViewModel>): ViewModel {
return MainSharedVM("MyVM")
}

Return

the ViewModel of the Activity or Fragment.

Parameters

modelClass

by default, Activity or Fragment will get the ViewModel by modelClass.newInstance().