One-Off Events with Channels
Deliver navigation and toast events safely.
State Is Not an Event
Some things should happen exactly once, like navigating or showing a toast. Modeling these as state causes them to replay on every rotation.
The Replay Problem
If you store a snackbar message in StateFlow, a configuration change re-reads it and the message pops up again unexpectedly.
All lessons in this course
- StateFlow vs SharedFlow
- Mapping & Combining Flows
- stateIn & WhileSubscribed
- One-Off Events with Channels