? Seems like an unnecessary dance to from event -> state -> lambda in compose -> snackbarhoststate (which internally converts the event into a state again) -> callback to viewmodel that the state was “consumed”.
Using
viewModelScope
to launch the snackbar would just suspend the launch call until the view is available it seems.. which is fine?
s
Stylianos Gakis
04/14/2024, 10:53 AM
Just do it. It’s not uncommon to hoist some state holder classes up there, like TextFieldState for example.
f
Francesc
04/14/2024, 4:06 PM
the way I think about it is, "does the viewmodel need to know about this?" If so, put it in the viewmodel, otherwise leave it in the compostable usually as a stateholder.
👍 3
t
Tobias Preuss
04/18/2024, 8:02 PM
Testing?
a
Alex
04/22/2024, 6:42 PM
It will live behind an injected interface @Tobias Preuss so testing won’t be an issue
Alex
04/22/2024, 6:43 PM
My intention is to avoid the dance from viewmodel -> state“event“ -> event -> back to state in snackbarhoststate
t
Tobias Preuss
04/22/2024, 7:39 PM
😶🌫️ I can't really judge. I have not used SnackbarHostState myself.