Coroutining Android apps
summary
Practical recipes for Kotlin coroutines: scope must be tied to lifecycle (use SupervisorJob in a CoroutineScope) or async work gets cancelled mid-send and messages get lost — replacing the Job in a new scope fixes that bug; avoid globalScope and create a new scope instead. Use withContext/dispatcher defaults inside suspend functions so callers don’t duplicate context. Inject a dispatcher provider for tests to run synchronously. Built a Retrofit adapter and tiny Rx-operator library and they work; Flow is cold (preview) and replaces many Rx use cases.
AI-written summary · about
chapters (18)
- 0:00Introduction and speaker background
- 4:25Coroutines vs callbacks and RxJava
- 7:39Structured concurrency basics
- 10:49Lifecycle-aware coroutines
- 14:00Choosing correct coroutine scope
- 17:56Global scope pitfalls
- 18:39Dispatcher selection best practices
- 20:07withContext function usage
- 22:57Main dispatcher behavior
- 25:02Self-contained suspend functions
- 27:15Retrofit and Room suspend support
- 30:06Testing with custom dispatchers
- 32:57Debugging coroutines
- 35:47Exception handling in coroutines
- 37:53Migrating from Java to Kotlin coroutines
- 39:21RxJava operators replacement
- 40:44Flow vs RxJava streams
- 43:15Coroutines limitations and future
