Managing state beyond ViewModels and Hilt
summary
Migrates from Hilt to Anvil to enable custom scopes and stop relying on Android ViewModel lifecycles, replacing scattered coroutine scopes and init leaks with a root/user/logged-out scope system that calls onEnterScope for resource startup. Implements a ViewModelFactory via Dagger multibindings, swaps ViewModels for presenter functions using Molecule (state-as-flow), renders via renderer bindings and templates, and tests by instantiating presenters and invoking onEnterScope or a TestScope.
AI-written summary · about
chapters (18)
- 0:00Introduction and motivation
- 1:13Dual-screen app architecture
- 2:38Problems with legacy state management
- 7:12Goals and design principles
- 8:13Migrating from Hilt to Anvil
- 11:46ViewModel factory with Anvil
- 13:33Implementing custom scopes
- 16:45Scope management in production
- 19:11Scoped interface for lifecycle
- 23:22Testing scoped components
- 24:04Recap of scope improvements
- 25:06Adopting unidirectional data flow
- 27:53Presenters and renderers
- 31:43Testing presenters and renderers
- 32:26Navigation with presenters
- 33:28Templates for dual-screen UI
- 35:33Unidirectional data flow explained
- 37:17Alternative libraries and summary
related talks
25mFully Understanding Dagger Hilt Migration from First Principles
30mArchitecting an app with MVP and ViewModels
41mBreaking ViewModels into smaller self-contained UI models
35mBreaking Up with Big ViewModels
40mComposing ViewModels: Breaking ViewModels into smaller self-contained UI models
42m(Unofficial) Guide to App Architecture Guide Vol. 2
35mModel View Intent, Embracing Reactive UI's
45mDagger Hilt: Live Code Tutorial, Pros and Cons
