Is there ever a reason not to use `MutableStateFlo...
# coroutines
m
Is there ever a reason not to use
MutableStateFlow.update { newValue }
vs.
.emit(newValue)
? Basically, just to be safe regarding concurrent updates?
a
do you mean specifically in the context of modifying/using the previous value as input? otherwise, when there is no need to for the current value, emit should probably be preferred?
m
Ah now I see, I read a medium article about how one should use update but somehow missed the part where this is only relevant when the previous value is part of creating the new value 😅 Makes way more sense this way, thanks
👍 1
a
If you aren’t using the previous value, you also can use
mutableStateFlow.value = newValue
, which doesn’t suspend whereas
emit
does
m
Are there no risks attached to updating the value without suspending?
a