Skip to content

Instantly share code, notes, and snippets.

@tfcporciuncula
Last active March 2, 2024 13:17
Show Gist options
  • Save tfcporciuncula/38c9f91923fc098b3a0646f97a9bb955 to your computer and use it in GitHub Desktop.
Save tfcporciuncula/38c9f91923fc098b3a0646f97a9bb955 to your computer and use it in GitHub Desktop.
val viewModelStoreOwner = requireNotNull(
LocalViewModelStoreOwner.current as? HasDefaultViewModelProviderFactory
)
val viewModel = viewModel<MyViewModel>(
extras = viewModelStoreOwner
.defaultViewModelCreationExtras
.withCreationCallback<MyViewModel.Factory> { factory ->
factory.create(runtimeArg = "abc")
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment