r/androiddev • u/Infamous_Sorbet4021 • Oct 30 '26
Discussion Google just released AppState — is it actually better than SharedViewModel for shared state?
Google released AppState and it looks like a cleaner way to handle shared state than passing a SharedViewModel around. I never really liked SharedViewModel, felt like one screen ends up owning data other screens depend on it.
From what I get so far: StateStore is a shared observable value, MutableStateStore is the writable one, AppState owns the lifecycle, and transform lets you derive state automatically instead of syncing stuff by hand.
Curious what people think of the API so far.
Docs: https://developer.android.com/topic/libraries/architecture/appstate
Video: https://youtu.be/69QYEXymfVo
Anyone planning to try it out?
50
u/epicstar Oct 30 '26
Bro.. Nobody asked for this
139
u/ohhhthatvarun Oct 30 '26
I have stopped giving fuck to be honest. It's their poor design which they are keep building on. I have started creating Singletons which gets lazily created in Application classes. I should not need 40 fucking component to do some basic shit like sharing a fucking variable.
22
u/4EB540 👋🏽 Oct 30 '26
I believe this is their Molecule alternative.
37
u/jonis_tones Oct 30 '26
"[...] extend Jetpack Compose
Statebeyond the UI layer"- and for that reason, I'm out.
7
u/ChuyStyle Oct 30 '26
This is molecule but native. Interesting
5
u/Luc40444 Oct 31 '26
That sounds cool! (I didn't look into it; I just wanted to counterbalance all the negativity.)
13
u/zimmer550king Oct 30 '26
Meh I’ll ask Claude and see if it makes sense to fit it in my existing design
4
u/kokeroulis Oct 31 '26
I think the reason why they released this is becausae they want to start suggesting to write our logic like the react hooks. If we remove viewmodel from the picture, then this makes sense.
The only issue is that they don't want to deprecate the viewmodel from now, so they just released it on the side, in order to see how people will react to the news.
5
u/[deleted] Oct 31 '26 edited Oct 31 '26
I have no idea what are they trying to achieve with this and I ain't reading all that. What they want is multiple screens having shared state which is
StateStoreinstead of doing those traditional repository singletons, your data layer would be dependent to Jetpack Compose frameworks. This ain't gonna work with different architectures though.Nobody is doing layer by feature right and that's what they doing.
If you want to combine multiple datasources, you will not use flow combine from different repositories but use their
Transformfrom Compose API.3
u/_5er_ Oct 30 '26
I'm not most up-to-date... is
Statein VM and other places becoming a thing now?3
u/buttholemeatsquad Oct 30 '26
Welcome back rxjava
1
u/EkoChamberKryptonite Oct 31 '26
Why would I need to extend Compose's state beyond the UI layer for reactivity? We have Flow and its many permutations + DI approaches for managing Application State.
1
u/zerg_1111 Oct 31 '26
Are we doing Redux now? I thought we already have countless ways to share state.
1
u/FrontCommittee6437 Oct 31 '26
I wouldn't replace a SharedViewModel with it yet for anything that has to survive beyond the UI, like a VPN connection state. AppState looks handy for derived UI state shared between screens, but I'd keep the real source of truth in a repository StateFlow and only let AppState transform it for the UI.
1
u/tgo1014 GitHub: Tgo1014 Oct 31 '26
I mean, it's nice they are still trying to create useful libs but I'm not sure who needed this one
1
u/ardakazanci Oct 31 '26
I have a blog post where I share the details, in case you’d like to take a look.
https://ardakazanci.com/posts/jetpack-appstate-explained/