azabost
10/11/2023, 8:42 PMFlow
• there is an active subscriber of that Flow
• a few changes in the observed table take place in the background
• the subscriber of the Flow
consumes the data slower than the updates are being made
In particular, I would like to know if the Flow
is going to emit every intermediate snapshot of the queried data or just the latest.
----data update A----------data update B-----------data update C-->
\
\
collected snapshot A & processing --------------------------------->finished
\
\
what's in the next collected snapshot? B or C?
David
10/12/2023, 7:01 AMazabost
10/12/2023, 10:40 AMFlow
with`conflate()` yesterday, hoping to always get the latest possible result from Room. It helped a lot but, unfortunately, it still didn't work the way I expected.
My case looked like this:
database.dataFlow()
.conflate()
.collect { values ->
// some processing
database.updateSomethingThatAffectsTheFlow(values)
}
It turned out that the change made by database.updateSomethingThatAffectsTheFlow()
was not reflected in the next collected value. I had to wait for yet another value to see that change 😕
I suspect that Room didn't have enough time to compute the new value for the Flow
before the subscriber became ready to receive the next update. Or something.