Kotlin Coroutines and Flows
summary
Covers concrete coroutine mechanics: suspend functions compile to continuations carrying a coroutine context, and coroutines run on Dispatchers.IO/Main/Default with withContext to switch threads. Demonstrates structured concurrency via scopes (viewModelScope, lifecycleScope) and cancellation (cancel children, isActive/yield). Shows channels (rendezvous, buffered, conflated, unlimited) and that flows are cold; operators include zip, combine, and flatMapMerge(concurrency=2) for parallel image fetches. Converts callbacks using suspendCoroutine and callbackFlow with offer/close/awaitClose. Mentions Kotlin coroutines beating Rx in a KotlinConf benchmark.
AI-written summary · about
chapters (15)
- 0:00Introduction
- 1:13Why coroutines matter
- 3:37Coroutines vs threads
- 5:00Suspend functions
- 6:25Launch vs async
- 9:16Structured concurrency
- 11:46Coroutine scopes and dispatchers
- 13:52Cancelling coroutines
- 14:34Channels for streaming
- 19:34Flows basics
- 23:49Flow operators
- 24:34Combining flows
- 27:42Flattening flows
- 29:26Converting callbacks
- 34:55Q&A
