compose-side-effects
Installation
SKILL.md
Compose: side effects
Core principle
Composable bodies describe UI. They can be recomposed, skipped, or abandoned. Work that changes the outside world belongs in an effect API whose lifecycle matches the work.
Pick the smallest effect
| Need | API |
|---|---|
| Publish Compose state to non-Compose code after every successful recomposition | SideEffect |
| Register/unregister a listener, callback, observer, or resource | DisposableEffect(keys...) |
| Run suspending, deferred, or keyed one-shot work | LaunchedEffect(keys...) |
| Launch suspending work from a user event callback | rememberCoroutineScope() |
| Convert Compose snapshot reads into a Flow inside a coroutine | snapshotFlow { ... } inside LaunchedEffect |
Effect keys
Keys define restart identity. When any key changes, the old effect is cancelled/disposed and a new one starts.