Elevated Dependency Injection: Going Beyond the Basics with Custom Hilt Components
summary
Patreon integrates a custom Hilt component called user component that scopes dependencies per signed‑in user, providing a per‑user coroutine scope and automatic cleanup on logout so background work and caches cancel and GC without manual threading or global maps. A copy module strategy copies user bindings into activity/viewmodel graphs so direct injection compiles and feels like app‑wide singletons; team adoption grows and the presenter says it’s worth using “a 100 times” in codebases.
AI-written summary · about
chapters (11)
- 0:00Custom Hilt components intro
- 3:56Default Hilt component limits
- 6:04Multi-user lifecycle issues
- 12:05Custom component step-by-step
- 15:13Access custom components in ViewModels
- 17:18Simplify with copy modules
- 21:14When to use custom components
- 22:18Testing custom components
- 24:21Are custom components right?
- 26:49Common pitfalls and how to avoid them
- 27:31Summary and demo
related talks
32mUsing Hilt in a Multi-Module Project
44mHilt: Dependency Injection for the mere mortals
40mFundamentals of Dependency Injection
43mDI for Dummies
42m(Unofficial) Guide to App Architecture Guide Vol. 2
28mThe Lazy (Meta)programmer's Guide to Hilt Extensions
30mThe Imposter’s Guide To Dependency Injection
25mFully Understanding Dagger Hilt Migration from First Principles
