Google is committed to advancing racial equity for Black communities. See how.

StableMarker

@Target([AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS]) annotation class StableMarker
androidx.compose.StableMarker

StableMarker marks an annotation as indicating a type is stable. A stable type obeys the following assumptions,

  1. The result of equals will always return the same result for the same two instances.
  2. When a public property of the type changes, composition will be notified.
  3. All public property types are stable.

A type that is immutable obeys the above assumptions because the public values will never change. The Immutable annotation is provided to mark immutable types as stable.

An object whose public properties do not change but is not immutable (for example, it has private mutable state or uses property delegation to a MutableState object, but is otherwise immutable), should use the Stable annotation.

Mutable object that do not notify composition when they changed should not be marked as stable.

When all types passed as parameters to a Composable function are marked as stable then the parameter values are compared for equality based on positional memoization and the call is skipped if all the values are the equal to the previous call.

Primitive value types (such as Int, Float, etc), String and enum types are considered, a priori, stable.

Summary

Public constructors

StableMarker marks an annotation as indicating a type is stable.

Public constructors

<init>

StableMarker()

StableMarker marks an annotation as indicating a type is stable. A stable type obeys the following assumptions,

  1. The result of equals will always return the same result for the same two instances.
  2. When a public property of the type changes, composition will be notified.
  3. All public property types are stable.

A type that is immutable obeys the above assumptions because the public values will never change. The Immutable annotation is provided to mark immutable types as stable.

An object whose public properties do not change but is not immutable (for example, it has private mutable state or uses property delegation to a MutableState object, but is otherwise immutable), should use the Stable annotation.

Mutable object that do not notify composition when they changed should not be marked as stable.

When all types passed as parameters to a Composable function are marked as stable then the parameter values are compared for equality based on positional memoization and the call is skipped if all the values are the equal to the previous call.

Primitive value types (such as Int, Float, etc), String and enum types are considered, a priori, stable.

See Also