kotlin-coroutines-flows

Document Kotlin coroutines and Flow patterns for Android and Kotlin Multiplatform projects.

3|2|Updated Mar 8, 2026
One-click install
npx skills add https://github.com/agentmatters/mullai-bot --skill kotlin-coroutines-flows-agentmatters
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-coroutines-flows
Source: https://github.com/agentmatters/mullai-bot/tree/main/src/Mullai.Skills/Skills/claude-code-everything/kotlin-coroutines-flows
Command: npx skills add https://github.com/agentmatters/mullai-bot --skill kotlin-coroutines-flows-agentmatters

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Kotlin Coroutines and Flow patterns that streamline asynchronous programming in Android and Kotlin Multiplatform projects, enabling robust, testable, and scalable data pipelines.

Core Features & Use Cases

  • Structured concurrency with coroutine scopes, async/await, and cancellation.
  • Flow-based data pipelines using Flow, StateFlow, and SharedFlow with UI state integration.
  • Testing guidance and practical examples for coroutine-based code across platforms.

Quick Start

Create a small coroutine-based data loader that updates a StateFlow with results.

Frequently Asked Questions about kotlin-coroutines-flows

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage asynchronous data streams with Kotlin Flow in Android?

Kotlin Flow manages asynchronous data streams by providing cold flows, hot StateFlow, and SharedFlow pipelines that integrate directly with Android UI state and lifecycle scopes for reactive data updates.

What is the best way to handle structured concurrency and cancellation in Kotlin Multiplatform?

Structured concurrency in Kotlin Multiplatform is handled by scoping coroutines to specific lifecycle scopes, ensuring child coroutines are automatically cancelled when the parent scope completes or fails, preventing memory leaks across shared platform code.

How do I test Kotlin coroutines and StateFlow across different platforms?

Testing Kotlin coroutines and StateFlow requires using test dispatchers like StandardTestDispatcher to control virtual time, allowing you to verify StateFlow emissions and asynchronous data loading behavior consistently across mobile and multiplatform environments.

When should I use StateFlow versus SharedFlow for UI state in Kotlin?

StateFlow is used for UI state when you need a single latest value held and replayed to new collectors, while SharedFlow is used for one-time events like navigation or showing Snackbars where holding state is unnecessary.

Does Kotlin coroutines structured concurrency work without extra dependencies in Kotlin Multiplatform projects?

Structured concurrency works in Kotlin Multiplatform projects by utilizing the kotlinx.coroutines library, which provides the necessary coroutine scopes, dispatchers, and cancellation mechanisms required for cross-platform asynchronous execution without platform-specific implementations.

Why does my Kotlin Flow pipeline drop emissions during configuration changes?

Flow pipelines drop emissions during configuration changes if collectors are tied to invalidated scopes; collecting from stable lifecycle scopes or using StateFlow ensures the latest state is retained and replayed when the UI recomposes.