Shape Shape point chapter-list Group Group Group Shape Copy 12 Shape Shape Copy 3 Shape Shape dropdown editor editor Combined Shape grid Shape Copy 4 Shape Copy 7 Shape language language Shape megaphone paperback Shape platform noun_419259-2 copy play-icon BS-Question-Rounded-Circle quotes noun_610406 stacked-books-1 stacked-books-2 Group Group Group Group Group

Kotlin Coroutines by Tutorials

$59.99 5/5 1 review · Write a Review
  • Platform Android 9
  • Language Kotlin 1.3
  • Editor AS 3.2

Android is inherently asynchronous and event-driven, with strict requirements as to on which thread certain things can happen.

Learn how to use Kotlin coroutines to solve common Android programming problems using asynchronous programming techniques!

Developer Guide


For Intermediate Developers

The importance of concurrency is discovered quite early on by people who start with Android development. Android is inherently asynchronous and event-driven, with strict requirements as to on which thread certain things can happen.

Add to this the often-cumbersome Java callback interfaces, and you will be trapped in spaghetti code pretty quickly (aptly termed as “Callback Hell”). No matter how many coding patterns you use to avoid that, you will have to encounter the state change across multiple threads in one way or the other.

The only way to create a responsive app is by leaving the UI thread as free as possible, letting all the hard work be done asynchronously by background threads.

Kotlin Coroutines by Tutorials will teach you the techniques you need to solve common programming problems using asynchronous programming.

We also recommend

Table of Contents

Section I: Introduction to Coroutines


What Is Asynchronous Programming?

In this very first chapter you’ll learn what asynchronous programming means and why a modern developer should understand it. You’ll see the basics of multithreading like queue and shared memory and you’ll understand how to solve the "Indentation Hell Problem."


Setting Up Your Build Environments

Learning through example is one of the most efficient ways to gain more skills. In order to do this, you need to set up your build environment and learn how to load the starting projects with IntelliJ or Android Studio. This chapter describes all you need in order to start writing your code.


Getting Started with Coroutines

This is the chapter where you’ll learn the main concepts about coroutines like builders, scope and context. You’ll see for the first time the Job object and learn how to manage dependencies between coroutines. You’ll understand and write code in order to manage one of the most important features of asynchronous tasks: cancellations.


Suspending Functions - New

In order to understand how to use coroutines you need to learn what a suspending function is and how to implement it. In this chapter you’ll learn all you need in order to create and use your own suspending functions. You’ll also learn how to change your existing functions in order to use them in a coroutine.


Async/Await - New

In multithreading and asynchronous development in Java, you often use Runnable, Callable and Future. With coroutines, you can use Deferred instead. These are objects that you can manage using the async/await functions. In this chapter you’ll write code in order to understand when and how to use this pattern in the most effective way.

Section II: Sequence, Context & Exceptions


Building Sequences & Iterators with Yield - New

Sequences are one of the most interesting features of Kotlin because they allow generating values in a lazy way. When you implement a sequence you use the yield function which is a suspending function. In this chapter you’ll learn how to create sequences and how the yield function can be use in order to optimize performance.


Coroutine Contexts & Dispatchers - New

Every coroutine is executed using a specific coroutine context which contains a set of information like the optional parent Job, dispatchers and any other information needed to manage cancelation. In this chapter you’ll learn how to use existing coroutine contexts and how to create your own.


Exception Handling & Cancellation

Using functions with a callback is not difficult only because of the indentation hell problem but also for error and exception handling. This becomes even worse if you want to make the function cancellable. In this very important chapter you’ll learn, with several examples, all the techniques you can use in order to handle exceptions and cancellations.

Section III: Channels & Operators


Channels - New

Although experimental, channels are a very important API you can use with coroutines. In this chapter you’ll create examples in order to understand what a channel is and how to act as a producer or consumer for it in a synchronous and asynchronous way. You’ll understand how to use multiple channels in case of multiple senders and receivers. You’ll finally compare channels with Java’s BlockingQueue.


Broadcast Channels - New

In this chapter, you’ll write many examples in order to experiment with using channels with multiple receivers and emitted items need to be shared by all of them.


Producers & Actors - New

In this chapter, you’ll learn how coroutines can help implement a producer/consumer pattern using different types of producers and consumers. Another approach to running tasks in the background is to use the actors model. In the second part of this chapter you’ll learn what an Actor is and how you can use it with coroutines.


Coroutine Operators - New

One reason Kotlin is a very successful language is that it makes functional programming easier. using operators you can make your code declarative and less error prone. Coroutines provide a different approach to concurrent programming and in this chapter you’ll learn how use operators with them.

Section IV: Coroutines in Android


Coroutine on Android - Part 1 - New

The Android platform allows you to run background tasks in many different ways. In this chapter, you’ll see and implement examples for all of them. You’ll learn what Looper and Handler are and when to use an AsyncTask. You’ll finally see how coroutines can make the code more readable and efficient.


Coroutine on Android - Part 2 - New

Learn how you can manage concurrency and multi-threading in Android and why coroutines can help you simplify and optimize code in many ways.


Coroutine on Android - Part 3 - New

The chapter covers fortifying the use of Kotlin Coroutines in an Android app i.e. Enabling logging, exception handling, debugging and testing of code that uses Kotlin Coroutines. Towards the end, Anko library will also be covered.

Meet the team

Average Rating

5 /5

Leave a review for this product

1 review

Kotlin Coroutines by Tutorials

Android is inherently asynchronous and event-driven, with strict requirements as to on which thread certain things can happen.

Learn how to use Kotlin coroutines to solve common Android programming problems using asynchronous programming techniques!