'How to check stability of a class inferred by Compose compiler?
There are @Immutable and @Stable annotations available for developers to mark their classes with. But I'm not quite sure when you need to annotate your classes and when it is inferred automatically. E.g. deeply-immutable data classes seems to be recognized as immutable by default. But you cannot be quite sure unless you log all @Composable calls and see how it behaves. And not knowing what is actually going on is somewhat infuriating for me as a programmer.
I wonder if there are more reasonable ways to see what immutability/stability Compose compiler infers for custom classes?
And if there are no clever ways to check it, what would be the rule of thumb for using @Immutable and @Stable annotations?
Solution 1:[1]
You can enable the compose compiler metrics to see what the compiler considers is stable. https://github.com/androidx/androidx/blob/androidx-main/compose/compiler/design/compiler-metrics.md
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dan Yang |
