Molecule: Using Compose for Presentation Logic
summary
Molecule turns Compose’s compiler plugin into a presenter builder so presentation logic runs as Compose code but without Compose UI dependencies. It exposes launchMolecule API returning a StateFlow, uses Compose primitives like mutableStateOf, remember and launchedEffect to cancel/restart work, and requires a recomposition clock (choose recomposition clock: context or immediate). Tests run with CashApp’s Turbine and immediate clock. Key behaviors: combines streams with ordinary Kotlin control flow and yields one emission per frame, matching the Android UI dispatcher.
AI-written summary · about
chapters (11)
- 0:00Molecule and Compose intro
- 2:25What Molecule lets us write
- 3:52Reactive programming on Android
- 9:35Flow and suspend limits
- 10:38Compose for presentation logic
- 15:53Why Molecule is needed
- 16:58Using Molecule in projects
- 19:54Recomposition clocks
- 21:40Building a search screen
- 23:24Testing Molecule presenters
- 24:25Key takeaways
related talks
27mBuilding State Holders in Compose with Molecule
38mBuilding StateFlows in Android with Jetpack Compose
42mDemystifying Molecule: Running Your Own Compositions For Fun And Profit
42mCompose: Beyond Android development
34mBeyond the UI: Compose as a Foundation for Multiplatform Apps
30mModern Compose Architecture with Circuit
31mModern Compose Architecture with Circuit
30mMolecule: a practical approach to ARCHITECTURE DESIGN
