Reactive App Orchestration with StateFlow
summary
StateFlow is presented as the coroutine primitive introduced in 1.3.6 (later sitting on SharedFlow) that replace ConflatedBroadcastChannel, represents a single read-only state that never completes, and always replays the latest value to new collectors. It needs a coroutine scope to collect, migrates from LiveData by swapping observe to collect with lifecycleScope.launch, tests with TestCoroutineScope by accumulating emitted states and asserting the list, and scales O(n) with n active collectors — adoption and testing are straightforward.
AI-written summary · about
chapters (24)
- 0:00Introduction to talk
- 0:14What is reactive app orchestration
- 1:38Coroutines and Flow basics
- 2:45Managing UI states with coroutines
- 3:50Limitations of BroadcastChannel
- 4:54StateFlow introduction and features
- 6:38StateFlow vs LiveData differences
- 9:30Adopting StateFlow in architecture
- 10:55Migrating ViewModel to StateFlow
- 11:59Migrating View to StateFlow
- 12:40Testing StateFlow implementations
- 14:26StateFlow vs LiveData summary
- 15:41Q&A session begins
- 16:02LiveData conversion with StateFlow
- 17:06Will StateFlow replace LiveData
- 18:29StateFlow hot vs cold channel
- 19:52Google’s stance on StateFlow
- 21:21Latency in StateFlow updates
- 22:06StateFlow subscription behavior
- 23:32StateFlow emission without collectors
- 24:16When to migrate to StateFlow
- 26:06Closing StateFlow collections
- 27:32StateFlow emission limits
- 28:34Closing remarks and Q&A
