Kotlin coroutines revolutionized JVM development, especially on Android and the backend. They let us easily make efficie
945 241 22MB
English Pages 470
Table of contents :
Table of Contents
Introduction
Part 1: Understanding Kotlin Coroutines
Why Kotlin Coroutines?
Sequence builder
How does suspension work?
Coroutines under the hood
Coroutines: built-in support vs library
Part 2: Kotlin Coroutines library
Coroutine builders
Coroutine context
Jobs and awaiting children
Cancellation
Exception handling
Coroutine scope functions
Dispatchers
Constructing a coroutine scope
The problem with shared state
Testing Kotlin Coroutines
Part 3: Channel and Flow
Channel
Select
Hot and cold data sources
Flow introduction
Understanding Flow
Flow building
Flow lifecycle functions
Flow processing
SharedFlow and StateFlow
Testing flow
Part 4: Kotlin Coroutines in practice
Common use cases
Recipes
Using coroutines from other languages
Launching coroutines vs. suspending functions
Best practices
The End