Making any codebase more readable with Kotlin coroutines
summary
Kotlin coroutines turn blocking I/O and callback-heavy code into straightforward suspending functions using kotlinx.coroutines with lifecycle scopes, dispatchers (Main, Default, IO) and structured concurrency. Examples show an 800+ line camera sample and a 1,000+ line Java version collapse to far fewer lines, and recording video in under five lines. Libraries bridge messy APIs (Bluetooth, Retrofit) via suspend wrappers; cancellation, timeouts and backpressure with flows/channels are demonstrated and shown to work in real Android use.
AI-written summary · about
chapters (24)
- 0:00Intro
- 1:34A readability (bad) example
- 4:02Thread offloading was inconvenient
- 4:31I had to use Bluetooth Low Energy
- 5:09I had to use Camera 2 API for video
- 6:22My code is often waiting
- 7:11Functions signatures
- 10:30Non blocking functions: keywords
- 12:34Writing your own composition
- 13:25Writing your own: parallel composition
- 14:36Writing your own: wrapping blocking code
- 15:29Dispatchers
- 16:27Cancellation != crash
- 16:43Cancelling a coroutine
- 16:59Cancel after timeout
- 17:43Writing your own wrapping simple callbacks
- 18:44Writing your own: wrapping callbacks
- 19:57Callback hell APIs: safe weapons
- 22:51Structured concurrency
- 23:53What about streams?
- 24:55Built into the language
- 26:21Continuation
- 28:29Roman Elizarov
- 29:22Growing libraries ecosystem
related talks
42mKotlin Coroutines: An Intro to Practical Use on Android
43mCoroutines for Java Developers
30mBetter asynchronous programming with Kotlin Coroutines
40mConcurrency made easy with Kotlin Coroutines
38mKotlin coroutines
44mTesting Kotlin Coroutines
01h 03mUsing Kotlin Coroutines for Asynchronous and Concurrent Programming
42mKotlin Coroutines: Beyond async/await
