0Pricing
Jetpack Compose Academy · Lesson

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

  1. StateFlow vs SharedFlow
  2. Mapping & Combining Flows
  3. stateIn & WhileSubscribed
  4. One-Off Events with Channels
← Back to Jetpack Compose Academy