Rihards10/05/2023, 12:52 PM
? I get multiple bottom sheets opened although the flow is triggered once. Also, if I put app on the background and re-open the app then extra bottom sheet is opened. blob nervous
Jonas10/05/2023, 1:07 PM
Kevin Worth10/05/2023, 1:20 PM
. You may be able to use
with 0 replay, instead. Your view starts listening and collects the publish, indicating it should open the sheet, but now when you have something like a configuration change (and you’ve `remember`ed that your sheet is open), it starts collecting again, but because replay is 0 it collects nothing.
to be similarly helpful when I want to fire off a signal to show a snackbar and don’t want to show it more than once (and also don’t want to have to “signal back” that the message has been consumed and can be cleared).
Rihards10/05/2023, 1:24 PM
Jonas10/05/2023, 1:25 PM
and also don’t want to have to “signal back” that the message has been consumed and can be clearedthe problem there is, that if the consumer is not ready (for example during a config change) the event could get lost.
Kevin Worth10/05/2023, 1:25 PM
The confusing/key part was being sure to pass in extraBufferCapacity as 1.
private val _snackbarMessage = MutableSharedFlow<String>(0,1, BufferOverflow.DROP_OLDEST) val snackbarMessage = _snackbarMessage.shareIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0)
may not always be the best option if it’s super important.
Jonas10/05/2023, 1:32 PM