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 = 1All lessons in this course
- StateFlow vs SharedFlow
- Mapping & Combining Flows
- stateIn & WhileSubscribed
- One-Off Events with Channels