Hi guys. My app architecture looks like: viewModel...
# compose
i
Hi guys. My app architecture looks like: viewModel + Compose layout per screen. In my viewModels I have Channel() where I handle actions from screen:
Copy code
init {
  viewModelScope.launch {
            try {
                actions.receiveAsFlow().collect { action ->
                    when (action) {
                                    //handle actions here
                   }
              }
        }
}
In
Home screen
I have list with post. The problem is when I select post and navigate user to
PostDetails screen
I can choose another post though list with post is underhood. I think it's related to
Home viewModel
and that action flow works in the background. Any solution what should I change?
t
If you're using navigation-compose,
NavHost
stacks each composable on the back stack, so you'll have to swallow gestures in your blue background there.
The source code for
ModalBottomSheetLayout
has a
Scrim
composable that shows how to do that with the
pointerInput
modifier, but there's probably an easier way.
i
FWIW, composables on the back stack of a
NavHost
are disposed (with only their state and ViewModel saved); they aren't present in the hierarchy to receive gestures at all