
▲ 28 r/androiddev
Embracing Compose Snapshot State for UI Layer State Production
Hi! I'm TJ and I wrote the Android state holder and state production docs some 4 years ago. Back then I highlighted 2 ways to produce state in a ViewModel for a Compose UI consumer:
With the well known and battle tested
StateFlowWith the new and somewhat quirky Compose snapshot
State
These days, to give your users the best Compose experience, and if your tooling allows, I think Compose State > StateFlow, even in the ViewModel. The blog post goes into detail why.
u/Alexorla — 2 days ago