Last active
February 1, 2026 17:11
-
-
Save CostaFot/443a48dc9687b9abe1ef0b4ec5051782 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
| @EntryPoint | |
| @InstallIn(ActivityComponent::class) | |
| interface CustomRetainedViewModelEntryPoint { | |
| fun customRetainedViewModel(): CustomRetainedViewModel | |
| } | |
| @Composable | |
| fun rememberCustomRetainedViewModel(): CustomRetainedViewModel { | |
| val context = LocalContext.current | |
| return retain { | |
| val entryPoint = EntryPoints.get(context, CustomRetainedViewModelEntryPoint::class.java) | |
| entryPoint.customRetainedViewModel() | |
| } | |
| } | |
| // compose layer | |
| @Composable | |
| fun FirstScreen() { | |
| val customRetainedViewModel = rememberCustomRetainedViewModel() | |
| val state by customRetainedViewModel.state.collectAsStateWithLifecycle() | |
| // .... rest of the owl | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment