Navigation and Dependency Injection in Compose
summary
Square’s patterns map DI into Compose by turning injected presenters into composable view-model structs, using molecule runtime to expose them as StateFlow and a Jetpack ViewModel to survive config changes. Backend uses Retrofit + protobuf/Wire, Room or SQLDelight, and Dagger/Anvil for injection. Navigation is just presenter state (example: a backstack implemented with Compose Backstack), and this scales — the described codebase runs nearly 1000 screens with a few hundred engineers. The approach produces testable flows and saved view state while keeping UI customization via runtime bindings.
AI-written summary · about
chapters (9)
- 0:00Introduction and motivation
- 3:22Problem with navigation and DI
- 7:15From Workflow to Molecule
- 10:50Handling multiple presenters
- 14:02Rendering UI from models
- 17:50Flexible UI binding strategies
- 20:35Navigation as app state
- 23:25Back stack with Compose
- 26:36Summary and Q&A
related talks
34mArchitectures in the Compose World
19mUsing Jetpack libraries in Compose
30mModern Compose Architecture with Circuit
34mBeyond the UI: Compose as a Foundation for Multiplatform Apps
35mPainless, Typesafe Jetpack Compose Navigation with Voyager
43mHelp! ViewModel
37mAdopting Jetpack Compose Safely
39mRe-Compose your UI: building an atomic design library
