https://kotlinlang.org logo
#flow
Title
# flow
e

Ed George

02/13/2021, 11:09 AM
Hi all, 99% sure I am using
SharedFlow
incorrectly, but would be good to understand why. My scenario is that I have an Android app with a list. When I click an item in the list, I call a method in my viewModel that emits a sealed class via a SharedFlow. The Android Fragment is collecting this flow and handling the UI based on the sealed class collected from it. However, clicking the same list item multiple times is not changing the UI multiple times - it seems like it happens occasionally and then emits multiple items should I change the item I click on (i.e. return a different instance of the sealed class) My question is, is there a way I can emit items every-time regardless of whether the previous item was the same item to be emitted? I am sure this is a fairly common question, but maybe I have not quite worked out how to google it successfully
m

miqbaldc

03/09/2021, 6:25 AM
this might related with yours: https://handstandsam.com/2021/01/15/my-mutablestateflow-didnt-emit/
p.s: the OP using
MutableStateFlow
3 Views