Do people feel that `StateFlow` is a good replacem...
# android
m
Do people feel that
StateFlow
is a good replacement for
LiveData
on Android? There is often a noticeable delay in updates, which leads to the UI to represent incorrect information when it first shows up. That never happened to me with
LiveData
.
m
I don't know what other ppl feel, but I can share with you what I feel... I feel is good for certain cases that happen to be fairly similar to those covered already by LiveData, I feel most people is using it lately just because is "the new kid on the block" rather than because is actually better. Personally when there's more than one tool to do the same job I would always go for the one known and proved to be good and safe, in this case at least for the ViewModels I stick with LiveData but in no way I'm saying I wouldn't use StateFlow for cases out of VM...
g
Flow is a lot more powerful and flexible I would never use LiveData if Flow was supported by DataBindings (fortunately soon I can drop it completely with AGP 7.0) I would check what kind dispatcher you use, it shouldn't be a visible difference between LiveData and Flow, try to measure actual update time in isolation
✔️ 2
2
c
Do you have an example that shows the stateFlow is slow with updating, or showing incorrect information at first? Someone here might be able to let you know if something is wrong.
m
@Martin Cazares @gildor @Colton Idle Sorry for cross-posting. Please continue the discussion in this thread: https://kotlinlang.slack.com/archives/C1CFAFJSK/p1623107841313900
When something goes wrong with databinding: 1) check
binding.lifecycleOwner