One of the hardest things to explain from Compose is class stability. Hopefully we can become fully agnostic of it eventually. Strong skipping is definitely helping us to get there, but I still find myself having to think about class stability every now and then.
Comments
I have some Composables that previously had a class param annotated with @Stable and now removed it when strong skipping was enabled, didn't notice any difference.
Except maybe taking care of everything in the class being VAL
Source https://developer.android.com/develop/ui/compose/performance/stability/strongskipping#when-skip
val instance1 = MyClass(1, "hello")
val instance2 = MyClass(1, "hello")
// During recomposition:
instance1 === instance2 // false - different instances, will trigger recomposition
// Later in recomposition, passing the same instance:
instance3 === instance3 // true - same instance, will skip recomposition
@Stable
data class MyClass(val integer: Int, val someText: String?)
val instance1 = MyClass(1, "hello")
val instance2 = MyClass(1, "hello")
// During recomposition:
instance1.equals(instance2) // true - will skip recomposition
I guess we still need stability annotations, makes sense when written down now.