Created
June 7, 2025 17:12
-
-
Save euri16/ae1656b14a41bad5df005023d1cc5e03 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 | |
| fun UserProfileScreen( | |
| viewModel: UserProfileViewModel = hiltViewModel() | |
| ) { | |
| // ... | |
| EffectHandler(viewModel.viewEffect, viewModel::processEvent) | |
| } | |
| @Composable | |
| private fun EffectHandler(effectFlow: Flow<ViewEffect?>, onEvent: (ViewEvent) -> Unit) { | |
| val navController = LocalNavHostController.current | |
| LaunchedUiEffectHandler( | |
| effectFlow, | |
| onConsumeEffect = { onEvent(ViewEvent.ConsumeEffect) }, | |
| onEffect = { effect -> | |
| when (effect) { | |
| // All your cases here | |
| } | |
| }, | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment