collecting-flows-safely
Installation
SKILL.md
Collecting Flows Safely — keep upstream work tied to the UI lifecycle
collectAsState() keeps collecting whenever the composable is in composition, including while the
app is backgrounded — that wastes CPU and battery. collectAsStateWithLifecycle() ties collection
to a Lifecycle.State (default STARTED) so backgrounding pauses upstream work. For chatty flows,
pair the consumer with .conflate() and .distinctUntilChanged() so Compose only sees meaningful
changes. Skydoves hot take #4: a Flow<T> parameter on a composable is unstable and blocks skipping
for the whole composable — collect at the caller and pass the resolved value.