koin-android-architecture / org.koin.android.architecture.ext / android.arch.lifecycle.LifecycleOwner / viewModelByClass
viewModelByClass
fun <T : ViewModel> LifecycleOwner.viewModelByClass(fromActivity: Boolean, clazz: KClass<T>, key: String? = null, name: String? = null, parameters: Parameters = emptyParameters()): Lazy<T>
Lazy get a viewModel instance
Parameters
fromActivity -
- create it from Activity (default true)
clazz -
- Class of the BeanDefinition to retrieve
key -
- ViewModel Factory key (if have several instances from same ViewModel)
name -
- Koin BeanDefinition name (if have several ViewModel definition of the same type)
parameters -
- parameters to pass to the BeanDefinition