Last active
March 1, 2024 08:47
-
-
Save tfcporciuncula/6595ced51397acb9da53b557d30f1927 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
val creationCallback: (MyViewModel.Factory) -> MyViewModel = { factory -> | |
factory.create(runtimeArg = "abc") | |
} | |
val viewModel = viewModel<MyViewModel>( | |
extras = requireNotNull(LocalViewModelStoreOwner.current).run { | |
if (this is HasDefaultViewModelProviderFactory) { | |
this.defaultViewModelCreationExtras.withCreationCallback(creationCallback) | |
} else { | |
CreationExtras.Empty.withCreationCallback(creationCallback) | |
} | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment