Rihards
10/05/2023, 12:52 PMModalBottomSheet
? 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 nervousRihards
10/05/2023, 12:57 PMJonas
10/05/2023, 1:07 PMJonas
10/05/2023, 1:19 PMKevin Worth
10/05/2023, 1:20 PMStateFlow
. You may be able to use SharedFlow
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.Kevin Worth
10/05/2023, 1:23 PMSharedFlow
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).Rihards
10/05/2023, 1:24 PMJonas
10/05/2023, 1:25 PMand 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 Worth
10/05/2023, 1:25 PMprivate val _snackbarMessage = MutableSharedFlow<String>(0,1, BufferOverflow.DROP_OLDEST)
val snackbarMessage = _snackbarMessage.shareIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0)
The confusing/key part was being sure to pass in extraBufferCapacity as 1.Kevin Worth
10/05/2023, 1:28 PMSharedFlow
may not always be the best option if it’s super important.Jonas
10/05/2023, 1:32 PM