Mastering Kotlin coroutines
Structured concurrency
Leverage coroutine scope hierarchies to avoid leaks and cancel work predictably.
Flows
Use Flow for cold async streams and StateFlow/SharedFlow for hot streams. Prefer suspend functions for one-shot work.
Testing
Use the TestScheduler and runTest to deterministically test coroutine-based code.