compose-side-effects

Guides correct use of LaunchedEffect, DisposableEffect, and other Jetpack Compose effect APIs.

Updated Jul 1, 2026
One-click install
npx skills add https://github.com/w0lzard/Wolzard-s-Marketplace --skill compose-side-effects-w0lzard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: compose-side-effects
Source: https://github.com/w0lzard/Wolzard-s-Marketplace/tree/main/plugins/personal-skills/skills/compose-side-effects
Command: npx skills add https://github.com/w0lzard/Wolzard-s-Marketplace --skill compose-side-effects-w0lzard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Jetpack Compose composables can be recomposed, skipped, or abandoned at any time, so running side work directly in a composable body causes duplicate network calls, leaked listeners, stale callbacks, and hidden lifecycle bugs. This Skill provides decision rules and code patterns for placing every kind of side work in the correct effect API. ## Core Features & Use Cases - Effect selection guidance: Maps each need (publishing state, registering listeners, keyed one-shot work, user-event launches, snapshot-to-Flow conversion) to the right API: SideEffect, DisposableEffect, LaunchedEffect, rememberCoroutineScope, or snapshotFlow. - Key and stale-capture rules: Explains how effect keys define restart identity and when to use rememberUpdatedState versus proper keying to avoid stale lambda captures. - Review checklist: Lists common mistakes and red flags such as LaunchedEffect(Unit) hiding changing inputs, missing onDispose cleanup, and event-flag state used to trigger effects. - Use Case: While reviewing a Compose screen that collects a Flow of snackbar events, use this Skill to confirm the collection belongs in a LaunchedEffect keyed by the event stream rather than in the composable body. ## Quick Start Ask the assistant to review your composable that uses LaunchedEffect, DisposableEffect, or snapshotFlow and check whether the effect keys and cleanup logic are correct.

Frequently Asked Questions about compose-side-effects

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose between LaunchedEffect and DisposableEffect in Compose?

Use LaunchedEffect for suspending, deferred, or keyed one-shot work like collecting event flows. Use DisposableEffect when registering and unregistering listeners, callbacks, or resources, since it provides the onDispose cleanup block.

When should I use rememberUpdatedState in Jetpack Compose?

Use rememberUpdatedState when a long-running effect must not restart but should invoke the latest callback, such as a timeout calling the newest onTimeout lambda. Do not use it to avoid keying an effect when the changed value should restart the work.

Why is LaunchedEffect(Unit) with changing parameters a bug?

LaunchedEffect(Unit) never restarts, so it keeps capturing the first value of any changing parameter like a userId. Key the effect by that parameter instead so the work restarts with the new value.

How do I collect a Flow in a Compose screen correctly?

Collect event or side-effect flows inside a LaunchedEffect keyed by the flow, triggering imperative work like snackbars or navigation. For UI render state, use collectAsStateWithLifecycle near the state holder and pass plain values into composables.

Can I launch a coroutine from a button click in Compose?

Yes, use rememberCoroutineScope to get a scope and call scope.launch inside the click callback for suspending work like showing a snackbar. Avoid setting event-flag state just to trigger a LaunchedEffect, since the click already is the event.