Introduction to Kotlin Coroutines

Coroutines for asynchronous programming

Satya Pavan Kantamani
Programming Geeks

--

Introduction

In most of the programming languages, it’s quite a common thing of doing synchronous tasks like hitting an API and waiting for the result to process the next steps, waiting for fetching data from the database, etc.

We basically started handling this using the callback mechanism. We do something like hitting an API and wait for the callback to get invoked where we process the result.

A callback is a function that will be executed after another function has finished executing. And if there are a series of things to be done synchronously then we will fall into callback hell that can lead us to ambiguity in understanding the code. It depends on the number of steps and logic we have in our applications.

To avoid this callback hell and with the difficulty of managing multiple threads at a time, we adopted Rx Java in Android where the code looks cleaner and easily understood.

Also, exception handling and disposing of things can be handled in a good way. The main problem with Rx is like exploring its list of operators in-depth while performing complicated operations and apply them correctly.

It is like learning another programming language called Rx Java to…

--

--

Satya Pavan Kantamani
Programming Geeks

Android Dev, Interested in Traveling, App development. Based in Hyderabad, India. Catch me at https://about.me/satyapavankumar