Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inline fun <reified T : ViewModel> Fragment.viewModel(
- crossinline provider: () -> T
- ) = viewModels<T> {
- object : ViewModelProvider.Factory {
- @Suppress("unchecked_cast")
- override fun <T : ViewModel?> create(modelClass: Class<T>) =
- provider() as T
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement