Tying UI and Data Lifecycles at the Compilation Stage
summary
Shows how annotated composables become real runtime scopes by wrapping function bodies to create a lifecycle owner and ViewModelStoreOwner, using currentCompositeKeyHash for stable keys and a parent ViewModel container to survive configuration changes. Disposal logic detects temporary versus permanent removal by checking parent resumed/visibility and uses remember/onForgotten hooks. Implementation uses a scoped composable pattern and a Kotlin compiler plugin to transform code at compile time so per-item view models are created and cleared correctly.
AI-written summary · about
chapters (10)
- 0:00Fine-grained composable scoping
- 1:04Understanding scoping
- 3:52Activity/fragment scoping limits
- 7:43Building composable scope
- 10:56ViewModel store in composables
- 14:44Lifecycle events for composables
- 17:14Electronics item example
- 19:46UI and data lifecycles at compile time
- 23:42Benefits of fine-grained scoping
- 24:35Q&A
related talks
34mArchitectures in the Compose World
41mViewModels, LiveData and Lifecycles, oh my!
28mLifecycle, LiveData, ViewModels - The inner wiring
43mHosting our states in Compose
38mLifecycles at Scale: with Multiplatform
43mHelp! ViewModel
23mLifecycle, LiveData, Viewmodels - The inner wiring
40mComposing ViewModels: Breaking ViewModels into smaller self-contained UI models
