KeyedFactory

interface KeyedFactory
androidx.lifecycle.ViewModelProvider.KeyedFactory

Implementations of Factory interface are responsible to instantiate ViewModels.

This is more advanced version of Factory that receives a key specified for requested ViewModel.

Summary

Public methods
abstract T
create(@NonNull key: String, @NonNull modelClass: Class<T>)

Creates a new instance of the given Class.

Public methods

create

@NonNull abstract fun <T : ViewModel!> create(@NonNull key: String, @NonNull modelClass: Class<T>): T

Creates a new instance of the given Class.

Parameters
key String: a key associated with the requested ViewModel
modelClass String: a Class whose instance is requested
<T> String: The type parameter for the ViewModel.
Return
T: a newly created ViewModel