Kotlin coroutines have revolutionized JVM development, especially on Android and the backend, as they let us easily impl
337 56 10MB
English Pages 469 Year 2021
Table of contents :
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
Notes