Asynchrony and the infinite conveyor belt: Advanced Coroutines and Flows
summary
Coroutines are tasks that can suspend and cancellation happens only when they yield — cancellation is implemented by cancellation throws CancellationException, so accidentally catching that exception (e.g., wrapping a suspend call in try/catch) can make a loop run forever. Dispatchers available: Main, IO, Default, Unconfined; use withContext or launch into a dispatcher. CoroutineScope is just a context wrapping a Job, which parents/children cancel hierarchically. Flows: cold vs hot, use shareIn with whileSubscribed and replay to avoid duplicate IO, and use stateFlow has .value current state for a single current value.
AI-written summary · about
chapters (18)
- 0:00Introduction to co-routines and the talk
- 1:27What is a coroutine
- 5:28Co-routines are tasks that can suspend
- 7:33How cancellation works in co-routines
- 9:43When cancellation occurs
- 12:34Danger of catching cancellation
- 14:43Launch vs async differences
- 15:46Coroutine scopes purpose
- 18:40Understanding dispatchers in co-routines
- 20:51Coroutine context metadata
- 22:20Jobs as coroutine handles
- 23:45Scope vs job explained
- 26:16Introduction to flows
- 27:18Cold vs hot flows
- 28:47Cold to hot flows
- 30:59Sharing flows configurations
- 32:45State flows and values
- 34:36Summary of coroutines and flows
related talks
32mStructured Concurrency: The paradigm shift
45mCoroutines, Flow & Android- The Good Parts
30mA deep dive on the lifecycle-aware coroutines APIs
43mCoroutines for Java Developers
40mConcurrency made easy with Kotlin Coroutines
40mDeep diving into the Kotlin Coroutines API
42mKotlin Coroutines: Beyond async/await
38mKotlin coroutines
