Created
February 20, 2022 18:03
-
-
Save thecodeside/b9e49d88c7369a65f66fcb740711feeb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun <reified VM : ViewModel> ComponentActivity.viewModels( | |
noinline customCreator: (() -> VM)? = null | |
): Lazy<VM> = | |
viewModels(factoryProducer = customCreator?.let { { ViewModelFactory(it) } }) | |
inline fun <reified VM : ViewModel> Fragment.activityViewModels( | |
noinline customCreator: (() -> VM)? = null | |
): Lazy<VM> = | |
activityViewModels(factoryProducer = customCreator?.let { { ViewModelFactory(it) } }) | |
inline fun <reified VM : ViewModel> Fragment.navGraphViewModels( | |
@IdRes navGraphId: Int, | |
noinline customCreator: (() -> VM)? = null | |
): Lazy<VM> = | |
navGraphViewModels(navGraphId, factoryProducer = customCreator?.let { { ViewModelFactory(it) } }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment