reflectViewModel

fun <VM : ViewModel> reflectViewModel(current: Class<*>, store: ViewModelStoreOwner, base: Class<*>? = null, createVM: (Class<out ViewModel>) -> ViewModel = ::createViewModel): VM

Creates an instance of the view model class to use.

Since

0.5.2

Parameters

current

The current class, maybe Activity or Fragment.

store

A ViewModelStoreOwner whose ViewModelStore will be used to retain ViewModels

base

If you provide this parameter, you can effectively reduce the number of recursions.

createVM

You need to provide this parameter when you need to create ViewModel instance which have parameters in constructor

VM

The class type of the ViewModel.