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.
Slides:
https://slides.com/tomashanley/kotlin...