Kotlin Coroutines: An Intro to Practical Use on Android
summary
Coroutines claim to replace callbacks and RxJava for Android by giving sequential-looking async code while actually supporting suspend functions, launch/async/deferred builders and withContext thread switches. Examples show cancellation via Job and cooperative cancellation (delay vs Thread.sleep), parallelism with async/await, dispatchers (commonPool defaults to cpu count) and Retrofit deferred adapters. Unit tests use runBlocking to run suspending code. Several production uses report success and the talk demonstrates concrete code patterns, gotchas, and testing strategies.
AI-written summary · about
chapters (16)
- 0:00Intro
- 1:34Outline
- 4:55Take an example... with callbacks
- 7:21What is a coroutine?
- 11:42What are Kotlin Coroutines?
- 17:47Coroutine Builders - async
- 20:21Coroutine Builders - runBlocking
- 21:53Using Thread Pools
- 24:23A note about threading...
- 28:18Switching Threads in a Coroutine
- 28:41Cancelling Coroutines
- 33:04Error Handling
- 34:09Testing
- 36:46Tips for starting in an existing app
- 38:30A Note on "Experimental" Status
- 41:12Any Questions?
related talks
44mTesting Kotlin Coroutines
40mBuilding Asynchronous Mechanisms in Android App, Using Kotlin Coroutines
38mKotlin coroutines
42mKotlin Coroutines: Beyond async/await
30mBetter asynchronous programming with Kotlin Coroutines
42mI Swapped RxJava for Coroutines. Why You Should Too
47mKotlin Coroutines
59mKotlin coroutines: new ways to do asynchronous programming
