https://kotlinlang.org logo
#android
Title
# android
l

Lilly

04/27/2020, 12:52 PM
Hi, is
Jetpack Compose
aware of configuration changes or should we still use
AAC ViewModel
for this purpose?
a

Adam Powell

04/27/2020, 1:51 PM
Hi! We're over in #compose if you'd like to join us there. If you mean to ask whether compose state is retained across activity recreation, there are the savedInstanceState functions but the non-parcelable variants aren't there yet. They'll be coming before long, but no immediate ETA. AAC ViewModel will work just fine until then.
l

Lilly

04/27/2020, 3:07 PM
Ahh nice thank you, I will join
So did I understand right, that AAC ViewModel will be replaced by these savedInstanceState functions when they are available?
a

Adam Powell

04/27/2020, 5:11 PM
The savedInstanceState functions are already there in compose, those handle cold process restart cases. The activity recreation in a live process case is the intermediate case that compose doesn't have API for yet.
l

Lilly

04/29/2020, 1:18 PM
Sure thats what I mean, my bad. But ViewModel's existence is still justified right? I have a lot of business logic within my Composable functions. Is it encouraged to move such code to a ViewModel or whats the best practice for handling business logic with compose?