Readonly Stateflow Cold To Hot

Expose state through `asStateFlow()` rather than an upcast of the mutable holder, and turn a cold source flow hot with `stateIn(scope, WhileSubscribed(timeout), initial)` so it survives collector churn without running forever. Use when a screen re-queries its source on every rotation or navigation, when work continues after the last collector leaves, or when something outside the owner is writing state it should only be reading.

maxrave-dev fce4d5c 6.0 KB Updated

File contents

maxrave-dev/kotlin-footguns/tree/main/skills/readonly-stateflow-cold-to-hot commit fce4d5c4d8

Frequently asked questions

npx skillmds@latest add maxrave-dev/readonly-stateflow-cold-to-hot