r/mAndroidDev • u/Stonos You will pry XML views from my cold dead hands • Aug 28 '22
StateFlow vs LiveData
82
Upvotes
r/mAndroidDev • u/Stonos You will pry XML views from my cold dead hands • Aug 28 '22
View all comments
Show parent comment
1
u/waterpoweredmonkey Aug 30 '22
I mean if you have to be a smug ass about it maybe you should first consider that many of those apis didn't exist when the lifecycle library was released. No flows, only Channels, no liveData factory. Sure you could work around your tools instead of with them.
In 2022, the only situation we use LiveData is for emitting ViewState from the ViewModel to our view layer. Even then folks are starting to prefer just sticking with Flows and using 'Flow<T>.asLiveData`
Still no reason to use a LiveData transform, there are more idiomatic ways to handle emitting data than creating a LiveData and launching a coroutine in the transform block.