I have a question about state management for snack...
# compose
a
I have a question about state management for snackbars. Currently we followed previous suggestion here about having a
showSnackbar
state and clearing it in on result, If user navigates to another screen before the snackbar result, the composable is not able to update its result because of cancellation. Then the user goes back to the Composable with a new composition and shows the snackbar again. Is there a better way of handling snackbarstates? Code in thread
Is there a better way of showing/hiding snackbars?
i
Are you just trying to set
showSnackBar
to false when your coroutine scope is cancelled? Generally, if you want code to run anytime the coroutine scope is completed (whether it completes normally or because the scope was cancelled), you'd put that in the
finally
block of `try`/`finally`
đŸ‘Œ 1
a
Ah, yes. That’s what we did now actually when we found the issue. So basically we pretty much have to use
try/finally
for screens which shows snackbars and can navigate to other screens. Thank you