Kotlin Coroutines Sample

Kotlin 1.1 comes with a new feature called Coroutines.

Quoting the official Kotlin blog:

Honestly, it’s hard to over-emphasize coroutines. The future has come, and we are stuck with it: we need non-blocking asynchronous APIs to keep up with the loads of data we are processing. We’ve been through callback hell and conquered it, but we deserve better. We want to simply write the code following its natural sequential logic, and let the compiler figure the asynchrony out for us. This is what coroutines are about: async/await, generate/yield, non-blocking IO, Rx and much more brought under the single unified paradigm of a suspending function. Such a function (or lambda) represents a computation that can be suspended (without blocking any threads) and resumed later.

For a better blocking, asynchronous and non-blocking APIs understanding I have created a github repository ( github.com/aleixmorgadas/kotlin-coroutines-sample ) with sample code. The project aims to show you how each type of API call is executed.

Have a nice coding day!

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center