Skipping, @Stable & @Immutable
Mark types so Compose can skip work.
Skipping, @Stable & @Immutable is a free Jetpack Compose Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Jetpack Compose Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
When You Need Annotations
Sometimes a type is truly safe but Compose cannot prove it. Annotations let you promise stability so skipping kicks back in.
The @Immutable Promise
@Immutable tells Compose that once an instance is built, none of its properties will ever change. It is the strongest stability guarantee.
@Immutable
data class Theme(val primary: Long, val radius: Int)When to Use @Immutable
Reach for @Immutable on config-like data: themes, styles, and value objects you create once and never mutate after construction.
The @Stable Promise
@Stable is gentler: properties may change, but when they do, Compose will be notified through Compose state. equals() must stay consistent.
@Stable for Observable Types
Use @Stable on classes whose mutable fields are backed by mutableStateOf, so Compose still tracks every change correctly.
@Stable
class FormState { var name by mutableStateOf("") }Break the Promise, Break Compose
These annotations are a contract. If you mark a type stable but mutate it silently, the UI shows stale data and bugs creep in.
Immutable Collection Helpers
Instead of List, pass ImmutableList from kotlinx.collections.immutable. Compose treats it as stable, so list Composables can skip.
fun Tags(items: ImmutableList<String>) { }Functions Stay Stable
Lambda parameters are stable already, but remember a lambda capturing changing values is a new instance each recomposition.
Mark the Whole Class Once
One annotation on the class covers every use of that type as a parameter. You do not annotate at each call site.
Annotations Are Last Resort
Prefer real immutability with val first. Only annotate when the compiler genuinely cannot infer stability on its own.
Verify, Then Trust
After annotating, check that the Composable actually skips. A wrong promise is worse than no promise at all.
Quick Check
Pick the right annotation.
Recap: Promise Wisely
Use @Immutable for never-changing data and @Stable for state-backed mutables. Honor the contract or the UI lies. ✅
Frequently asked questions
Is the “Skipping, @Stable & @Immutable” lesson free?
Yes — the full text of “Skipping, @Stable & @Immutable” is free to read here on the web, and the Jetpack Compose Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Jetpack Compose Academy course, upgrade to CoddyKit PRO.
What will I learn in “Skipping, @Stable & @Immutable”?
Mark types so Compose can skip work. You practise Jetpack Compose Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Jetpack Compose Academy?
No prior experience is required. Jetpack Compose Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Skipping, @Stable & @Immutable” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Jetpack Compose Academy lesson?
Yes. Every Jetpack Compose Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Stable vs Unstable Parameters
- Skipping, @Stable & @Immutable
- Deferring State Reads
- Layout Inspector & Recomposition Counts