tjohnn
07/18/2020, 4:37 AMdata class Count(var value: Int = 0)
private val count = MutableStateFlow(Count())
val newCount = count.value
newCount.value++ // no emission though value is updated
count.value = newCount // this does not emit either
Zach Klippenstein (he/him) [MOD]
07/18/2020, 4:49 AMtjohnn
07/18/2020, 6:00 AMMark Murphy
07/18/2020, 11:41 AMStateFlow
uses content equality (==
) and only emits values when the object contents differ.
See "Strong equality-based conflation" in the StateFlow
docs: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html
See also this sample demonstrating the effect: https://klassbook.commonsware.com/lessons/Flows%20and%20Channels/stateflow-equality.htmltjohnn
07/18/2020, 4:13 PM