collecting-flows-safely
CommunityTies flows to UI lifecycle for calmer Compose.
System Documentation
What problem does it solve?
Collecting flows in Compose can keep collecting even when the app is backgrounded, wasting CPU and battery. This skill guides migrating to collectAsStateWithLifecycle, hoisting Flow parameters, and applying conflate() / distinctUntilChanged() and snapshotFlow to tie work to lifecycle.
Core Features & Use Cases
- Migrate external Flow sources to lifecycle-aware collection with collectAsStateWithLifecycle.
- Hoist Flow<T> parameters to the caller and collect at the appropriate boundary.
- Use .conflate() and/or .distinctUntilChanged() for high-frequency streams; leverage snapshotFlow for State-to-Flow bridges.
- Add minActiveState awareness to focus widgets and ensure background pausing works as intended.
Quick Start
Audit your module for external flows and replace collectAsState() with collectAsStateWithLifecycle(), hoist Flow parameters to the caller, and add .conflate() / .distinctUntilChanged() where needed while using snapshotFlow for State→Flow patterns.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: collecting-flows-safely Download link: https://github.com/skydoves/compose-performance-skills/archive/main.zip#collecting-flows-safely Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 510,000+ vetted skills library on demand.