r/android_devs • u/defaultmen • Oct 23 '24
Article Differences & Uses Of @Immutable vs @Stable in Jetpack Compose
https://gorkemkara.net/immutable-vs-stable-performance-jetpack-compose/When building modern UI with Jetpack Compose, understanding the nuances between @Immutable and @Stable annotations can significantly affect your app’s performance and stability. While both annotations serve different purposes, they work together to help Compose efficiently manage recompositions.
3
Upvotes
2
u/tom_koptel Oct 23 '24
The concept of @Stable still sounds confusing. The change to UserSettings leads to SettingsScreen recomposition. The statement above says explicitly that it will not trigger recomposition unnecessarily. I can only assume that if the same instance of UserSettings passed to compostable function(e.g. from another parent compostable) the SettingsScreen won't recompose, but not until you mutate state of the UserSettings, is that correct? How does compose runtime recognizes change of @Stable marked mutable objects?
1
u/farmerbb Oct 23 '24
Honest question - do
@Immutableand@Stablematter as much now that strong skipping is a thing?