5 Common Traps You Can Step Into When Using Coroutines
summary
Five concrete mistakes and fixes for Kotlin coroutines with code-level details: executing independent suspending calls sequentially instead of using async + awaitAll or mapping to individual awaits, forgetting coroutines are not cancelable by default and needing suspendCancellableCoroutine plus FusedLocationProviderClient and CancellationTokenSource, failing to make suspend functions main-safe by switching dispatchers, catching CancellationException unintentionally, and exposing suspend functions to the UI instead of using viewModelScope and state holders like StateFlow.
AI-written summary · about
chapters (5)
- 0:00Introduction to coroutines
- 1:10Sequential API calls mistake
- 5:44Making coroutines cancellable
- 10:43Cancellation exception handling
- 13:57Exposing suspend functions in ViewModel
related talks
37mPractical Patterns for Kotlin Coroutines in Production
37mCoroutines! Gotta catch 'em all!
45mAll the Pitfalls of Coroutines
49mLaunching Into Coroutines
36mCracking Kotlin Coroutines
47mKotlin Coroutines
28mMy coroutines patterns and habits, 3 years later
42mKotlin Coroutines: An Intro to Practical Use on Android
