I’ve a question related to Compose and Coroutine. ...
# compose
f
I’ve a question related to Compose and Coroutine. Would it be an issue doing something like this
Copy code
//TOP level composable of the app
with(LocalLifecycleOwner.current) {
    lifecycleScope.launch {
        navigationManager.navigationEvents
            .flowWithLifecycle(lifecycle, Lifecycle.State.STARTED)
            .collect { navigationDirection ->
            //Listening to navigation event
            navController.navigate()...          
            }
    }
Or should I do it in LaunchEffect ? Since Compose function can execute in any order, I wanted to avoid to have it a LaunchEffect and use a replay parameter of a Flow. (eg: Sending a event before the collection,)
m
since that does not use remember, yes. that is a problem
f
Ok so if I get, using the block inside the remember with the Locallifecycle.current as key should be sufficient ? And what would be the difference doing this in LaunchEffect(Unit)?
z
Your concern about missing navigation events is exactly why your compose ui layer should not be the one handling such events. Navigation events should update some state, and that state should be consumed by composables.