Last active
February 18, 2026 22:33
-
-
Save CostaFot/6bc53ed85bc001dabd90ba615b49ae50 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @Composable | |
| inline fun <reified T : RetainedViewModel> rememberRetainedViewModel(noinline factory: (Context) -> T): T { | |
| val context = LocalContext.current | |
| return retain { factory(context) } | |
| } | |
| // ..compose layer | |
| val customRetainedViewModel = rememberRetainedViewModel { context -> | |
| EntryPoints.get(context, CustomRetainedViewModelEntryPoint::class.java).customRetainedViewModel() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment