kp-flow-cold-vs-hot
Installation
SKILL.md
One-line summary
Flow is cold (re-runs per collector), SharedFlow is hot and broadcast (no required current value, optional replay), StateFlow is hot and conflates (always has a current value). Pick by what the consumer needs: a fresh execution, an event stream, or current state.
When to use this skill
- Designing an API that exposes a stream of values.
- Refactoring callback-based code into a coroutines-friendly stream.
- Confusion between which Flow variant to use for a given use case (UI state, server-sent events, periodic polling, etc.).
When NOT to use this skill
- A single async value — use
suspend funorDeferred<T>. - A bounded list of values that's available all at once — use
List<T>orSequence<T>.
Core content
Flow<T> — cold. Lazy by construction; the producing code runs only when a collector starts collecting, and re-runs from scratch for each new collector. Each collector gets its own independent run.