ViewModelStoreOwnerRegistry

No need to access this directly.

The ViewModelRegistry makes ViewModels and their interfaces available to child Fragments via scopedInterface and scopedViewModel.

It keeps a WeakReference to the ViewModelStoreOwner creating the ViewModel. This ensures that ViewModels can be resolved as long as the component that created it is alive and it's automatically cleaned up if no other reference to ViewModelStoreOwner is kept in memory.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class Interface(val interfaceClass: KClassifier, val key: String)
Link copied to clipboard
data class ViewModelClass(val className: String, val key: String)

Functions

Link copied to clipboard
fun <VM : ViewModel> get(viewModelClass: KClass<VM>, extraKey: String): ViewModelStoreOwner?
Link copied to clipboard
fun getViewModel(myInterface: KClassifier, extraKey: String): KClass<out ViewModel>?
Link copied to clipboard
fun <VM : ViewModel> put(viewModelClass: KClass<VM>, extraKey: String, owner: ViewModelStoreOwner)
Link copied to clipboard
fun <VM : ViewModel> registerInterface(interfaceClass: KClass<out Any>, key: String, viewModelClass: KClass<VM>)