How does the StateFlow `.value` work? I’m seeing i...
# coroutines
s
How does the StateFlow
.value
work? I’m seeing instances where values are `emit`ted from the
Flow
, but then the
.value
is never updated to reflect the result that was either set on
.value
or
emit
on the
Flow
.
z
are you immediately setting it to multiple values in very quick succession?
s
No. I found the problem. It was a bug in my code
d
@Zach Klippenstein (he/him) [MOD] Can you please explain what happens in that case, when you’re emitting multiple values very quickly? I had a similar issue and didn’t really understand what’s the problem.
z
MutableStateFlow
conflates values. If the same value is set multiple times, it will only be emitted once, and if multiple distinct values are set before they can be emitted, then some will be dropped.
👍 1