0PricingLogin
Jetpack Compose Academy · Lesson

StateFlow vs SharedFlow

Choose the right hot stream for the UI.

Hot Streams for the UI

To stream live data into Compose you use a hot flow that stays active and emits whether or not anyone is currently collecting it.

Meet StateFlow

A StateFlow always holds exactly one current value. New collectors immediately receive that latest value, which is perfect for screen state. 📦

val count = MutableStateFlow(0)
count.value = 1

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