Get Ready to Duck: Coroutines with an Air Cannon
summary
Live code shows Kotlin coroutines controlling an IoT ping‑pong air cannon that connects via the Particle microcontroller and the Particle cloud, using Retrofit with suspend functions to fetch devices and call functions; the cannon actually fires and reports pressure. Demonstrates switching dispatchers (Dispatchers.IO), using async/await deferred for concurrent siren and fire actions, explains GlobalScope as an anti‑pattern, structured concurrency with scope/job, and proper cancellation cleanup with try/finally so the siren turns off.
AI-written summary · about
chapters (10)
- 0:00Introduction to co-routines
- 1:09Live coding setup
- 2:56Retrofit and network calls
- 7:18Main thread walkthrough
- 13:58Launching the air cannon
- 16:07Adding the air raid siren
- 19:44Concurrent operations
- 22:15Structured concurrency
- 26:13Cancelling co-routines
- 31:39Q&A session
related talks
43mAsynchronous programming using Coroutines
40mDeep diving into the Kotlin Coroutines API
30mBetter asynchronous programming with Kotlin Coroutines
36mCracking Kotlin Coroutines
28mMy coroutines patterns and habits, 3 years later
20mLean Async Code with Kotlin's Coroutines
45mCoroutines, Flow & Android- The Good Parts
35mEfficient Async with Kotlin Coroutines
