Composing ViewModels:Breaking ViewModels into smaller self-contained UI models
summary
Micro-features replaces one giant ViewModel with many self-contained UI models backed by a root Jetpack ViewModel that passes scope and SavedStateHandle; 80–90% of the existing domain layer stays reusable. Each micro-feature provides factory APIs for a composable and a UI model, registers/unregisters by logical configuration to show context-aware sets of items, and supports moving components between hosts. Implementation uses Compose, assisted factories, Kotlin Multiplatform-friendly UI models, and testing via unit tests, screenshot tests with Paparazzi and Espresso for integration plus end-to-end flows.
AI-written summary · about
chapters (14)
- 0:00Introduction to micro-features
- 3:39Architecture requirements for new design
- 8:12Introducing micro-features concept
- 10:38UI model vs ViewModel comparison
- 14:30Composing ViewModels with micro-features
- 15:56Micro-feature architecture blueprint
- 17:22Implementing a micro-feature example
- 23:26Hosts and micro-feature integration
- 27:20Binding UI models and composables
- 30:30Scaling with dynamic host configuration
- 33:59Portability and multi-platform benefits
- 36:11Server-driven UI compatibility
- 37:34Testing strategies for micro-features
- 39:01Future improvements and next steps
related talks
40mComposing ViewModels: Breaking ViewModels into smaller self-contained UI models
41mBreaking ViewModels into smaller self-contained UI models
35mBreaking Up with Big ViewModels
43mHelp! ViewModel
29mModern Android Development using MVI architecture
34mArchitectures in the Compose World
38mArchitecture Agnostic UI Development
22mBloated ViewModels? What Next
