Aidan Low
06/21/2022, 8:56 PMawaitItem()
I seem to see each individual time the StateFlow was set, but what I care about is the eventual value after a number of operations. It manifests most painfully in my combine-heavy view model with a lot of .stateIn()
operations but can also be seen in
val stateFlow = MutableStateFlow(false)
stateFlow.test {
stateFlow.value = true
val a = awaitItem() // this is false
val b = awaitItem() // this is true
}
Trevor Stone
06/21/2022, 8:58 PMstateFlow.filter{}.test{ awaitItem() }
Trevor Stone
06/21/2022, 8:58 PMAidan Low
06/21/2022, 9:00 PMephemient
06/21/2022, 9:01 PMephemient
06/21/2022, 9:02 PMdelay(100)
expectMostRecentItem()
with caveats about timingAidan Low
06/21/2022, 9:02 PM