How do LiveData and Coroutines actually work
summary
Explains that LiveData is just a data holder and the config-change “magic” comes from Activity keeping a ViewModelStore via retainNonConfigurationInstance so ViewModelStore is just a HashMap holding ViewModel instances across recreation, not LiveData surviving by itself. Demos coroutines: suspend functions compile to continuations and a label-driven state machine — suspend functions become a switch-based state machine — and benchmarks 100 coroutines vs a 4-thread executor fetching example.com (coroutines ~2s faster) — 100 coroutines vs 4-thread pool fetch example.
AI-written summary · about
chapters (13)
- 0:00Intro
- 1:28Agenda
- 4:34LiveData
- 10:28Fragment
- 14:11Model Provider
- 15:26Surviving Configuration Change
- 18:00Surviving Configuration Change API
- 20:19Coroutines
- 21:54Documentation
- 23:28Example
- 28:19How Coroutines work
- 37:29Coroutines in Java
- 43:39Questions
related talks
38mMigrating from LiveData to Coroutines and Flow
48mHow Do LiveData, Coroutines, and Nav Component Actually Work
23mLifecycle, LiveData, Viewmodels - The inner wiring
45mDeep Dive into Coroutines on JVM
38mUnderstand Kotlin Coroutines on Android
19mFun with LiveData
28mConcurrency for Imposters
28mLifecycle, LiveData, ViewModels - The inner wiring
