Effective Coroutines
summary
Claims that suspend is not magic and that coroutines require mastering scopes and builders drive a concrete puzzle: a monitor-and-scan example initially prints "done" immediately then later "starting" and never "scanning." Fixes use coroutine builders, await/async (or awaitAll), channels and a conflatedBroadcastChannel to communicate progress so output becomes "starting scanning done." Scopes act as scope = job + dispatcher, viewModelScope and kotlinx-coroutines-test are recommended tools.
AI-written summary · about
chapters (18)
- 0:00Introduction
- 0:56Motivated by
- 1:50Geometry
- 2:44Puzzler
- 6:09Key Concepts
- 6:39Suspended Functions
- 8:07The old way
- 10:11Life
- 11:04Job
- 11:30Scope
- 14:51Cleanup
- 15:05Structure Concurrency
- 16:10Cancellation
- 16:31Summary
- 21:53Channel Example
- 26:15Flows
- 30:19Official view
- 31:24Questions
related talks
59mKotlin coroutines: new ways to do asynchronous programming
49mLaunching Into Coroutines
40mConcurrency made easy with Kotlin Coroutines
47mKotlin Coroutines
37mPractical Patterns for Kotlin Coroutines in Production
37mCoroutines! Gotta catch 'em all!
46mIntroduction to Coroutines
42mKotlin Coroutines: Beyond async/await
