https://kotlinlang.org logo
#coroutines
Title
# coroutines
s

spierce7

05/18/2021, 10:24 PM
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

Zach Klippenstein (he/him) [MOD]

05/18/2021, 10:26 PM
are you immediately setting it to multiple values in very quick succession?
s

spierce7

05/18/2021, 10:39 PM
No. I found the problem. It was a bug in my code
d

Dean Djermanović

05/19/2021, 6:44 AM
@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

Zach Klippenstein (he/him) [MOD]

05/19/2021, 7:01 AM
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
3 Views