KotlinConf 2019: Coroutines Case Study - Cleaning Up an Async API by Tom Hanley
Recording brought to you by American Express. https://americanexpress.io/kotlin-jobs Asynchronous code can get really messy really quickly. Callback hell was named callback hell for a reason. There are some good ways to avoid this in your design, but sometimes you have to live with some old hard to use async API. Maybe because it's provided by a third party, or maybe it's just too difficult to rip out and rewrite. What you can do in this case is write a Kotlin extension/wrapper on top of the API. Kotlin #Coroutines are a fantastic way to clean up async APIs. They can make your async code as easy to read and understand as sequential code, but give you all the benefits of non blocking async code. In this session I'm going to show you how I took an asynchronous API for interacting with external hardware on Android, and wrote a Kotlin extension on top of it using coroutines and channels to make it super clean and easy to use. I'll also be sharing some of the key lessons learned along the way including error handling, debugging tools, and keeping your coroutines clean and testable. Resources: KotlinConf website: https://jb.gg/fyaze5 KotlinConf on Twitter: https://twitter.com/kotlinconf Kotlin website: https://jb.gg/pxrsn6 Kotlin blog: https://jb.gg/7uc7ow Kotlin on Twitter: https://twitter.com/kotlin #KotlinConf19 #Kotlin #JetBrains About the Presenter: Tom is a backend Java engineer turned passionate Kotliner. At Toast he has been instrumental in adopting Kotlin in their Android POS as well as backend services. He is a big proponent of Kotlin both in Toast and in the Dublin developer community, organising the Kotlin user group as well as presenting at the Google developer group and the Belfast KUG. He has most recently been working on Kotlin Android libraries and Android card reader integrations at Toast. His hobbies include all things food, adventure racing, golfing, running and hiking.