Skip to main content
InterviewHubPRO
Section Overview
Q19

Question 19 of 50

Part 2: Compose Internals, Persistence, DI & Background Work (11 - 24)

38%
Android & Jetpack Compose (50 Qs)•Part 2: Compose Internals, Persistence, DI & Background Work (11 - 24)

What makes a Composable function "Skippable" and what are `@Stable` and `@Immutable`?

senior LevelDocker & Containers

In Simple Words: Compose skips recomposition only if all parameter types are Stable:

  • Primitive types (Int, String), functional lambdas, and classes marked with @Immutable are considered stable.
  • The Stability Trap: Standard Kotlin List<T> is an interface; Compose treats it as unstable because a subclass could be mutable (ArrayList), causing the composable to recompose on every parent update!
  • Fix: Use Kotlinx Immutable Collections (ImmutableList<T>), or annotate the data class with @Immutable.