Junior — Middle
What is the purpose of the @Immutable annotation in Jetpack Compose and how does it affect interface behavior?
sobes.tech AI
Answer from AI
The @Immutable annotation in Jetpack Compose indicates that an object or class is immutable. This means that the state of the object does not change after creation. In the context of Compose, this helps the system optimize UI redraws, as immutable objects do not require reprocessing when updating the UI.
For example, if a function parameter is marked as @Immutable, Compose can skip a recomposition if the reference to the object has not changed, which improves performance.