If I have a Stateflow is there a difference betwee...
# coroutines
d
If I have a Stateflow is there a difference between
emit(newValue)
and
value = newValue
like there was for post/value in Livedata? I'm not seeing any documentation, I think we're supposed to use Emit, but using value = appears to be working in my code?
z
Emit will suspend in some cases. The kdoc on the function explains more. Setting the value property never suspends.
However MutableStateFlow never experiences back pressure (it always has “drop oldest” behavior), so emit will never suspend. It’s just there because MutableStateFlow extends MutableSharedFlow
It’s much more idiomatic to use the value setter when working with MSF
d
Cool, thanks for the info!
o
@Zach Klippenstein (he/him) [MOD]
However MutableStateFlow never experiences back pressure (it always has “drop oldest” behavior), so emit will never suspend. It's just there because MutableStateFlow extends MutableSharedFlow
Inheritance🙁
z
yea 😞