Skip to content

Instantly share code, notes, and snippets.

@euri16
Created June 7, 2025 17:12
Show Gist options
  • Select an option

  • Save euri16/ae1656b14a41bad5df005023d1cc5e03 to your computer and use it in GitHub Desktop.

Select an option

Save euri16/ae1656b14a41bad5df005023d1cc5e03 to your computer and use it in GitHub Desktop.
@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