Coroutines, Flow & Android- The Good Parts
summary
Concrete rules and gotchas: avoid no heap allocated coroutine scope references because storing a scope (transaction.executeIn example) silently drops launched work; don’t use GlobalScope or MainScope for presenters; prefer use suspend functions over firing non-suspending APIs (trash‑can concurrency) so callers get results and control; prefer StateFlow over SharedFlow for shared state (synchronous value via value, bootstrap with a suspending init), and use lifecycle/compose helpers or channels to manage scope lifetime and avoid leaks.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 2:09Structure concurrency basics
- 8:06Heap allocated scope risks
- 10:15Dos and don'ts for scopes
- 13:05Avoid global scope
- 17:38Trash can concurrency
- 20:04Flows and cooperation
- 24:56What is a flow
- 27:00Root coroutines
- 30:54Sharing state between coroutines
- 34:24Why avoid SharedFlow
- 35:07StateFlow superpowers
- 36:33StateFlow pitfalls
- 39:03Bootstrapping state
- 41:33Leaking collections
- 42:37StateFlow transforms
- 44:02Summary and Q&A
related talks
28mMy coroutines patterns and habits, 3 years later
36mAsynchrony and the infinite conveyor belt: Advanced Coroutines and Flows
44mGoing with the Flow - Using Coroutines 1.3.x
38mAndroid Coroutines: How to manage async tasks in Kotlin
36mGo with the Flow
42mGo with the Flow
57mFunctional Android apps
36mCracking Kotlin Coroutines
