fun <VM : ViewModel> Fragment.viewModel(key: String? = null, factory: () -> VM): VM
Generic view model provider.
key
- The key to use to identify the ViewModel.
factory
- Function creates a new instance of the ViewModel.
Return
A ViewModel that is an instance of the given type VM.
See Also