Hi everyone
I’m implement android app by Jetpack Compose, control ui state with stateFlow and handle one-time event with shareFlow (navigate, show loading, … )
I have found an issue where SharedFlow does not collect values when the activity is open. So I set replay = 1, which worked fine initially.
However, I found that when the app is sent to the background (eg. using the home button) and then brought back to the foreground, the SharedFlow collects values again, which seems to be because of the replay = 1 setting.
What can I do to prevent SharedFlow from collecting values multiple times upon resuming the activity? Are there any alternative approaches or configurations to handle this scenario effectively?
And finally, for handling one-time events, should we use StateFlow or SharedFlow?