kotlin-coroutines-flows

Implement structured concurrency and Flow-based state management in Kotlin.

1|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/xxih/ai-harness-zh --skill kotlin-coroutines-flows-xxih
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-coroutines-flows
Source: https://github.com/xxih/ai-harness-zh/tree/main/references/translations/everything-claude-code/docs/zh-CN/skills/kotlin-coroutines-flows
Command: npx skills add https://github.com/xxih/ai-harness-zh --skill kotlin-coroutines-flows-xxih

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

在 Android 和 Kotlin Multiplatform 项目中,简化异步编程、响应式数据流和测试的实现,避免回调地狱、手动协调状态和取消。

Core Features & Use Cases

  • 结构化并发、Flow 操作符、StateFlow/SharedFlow 的用法与实践,提升数据流的可靠性与可测试性。
  • 支持跨平台模块的协程设计与并发组合,帮助实现高效的 UI 数据绑定与状态管理。
  • 提供常见场景示例:并行数据源获取、错误处理、取消与回滚、以及测试友好的架构。

Quick Start

实现一个使用结构化并发和 Flow 的小模块,并并发获取多个数据源并将结果通过 StateFlow 暴露给 UI.

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 flows in Kotlin Multiplatform?

Manage asynchronous data flows in Kotlin Multiplatform by applying structured concurrency and Flow operators. This approach simplifies reactive state management and prevents callback hell across shared KMP modules.

What is the best way to handle state management with StateFlow in Android?

The best way to handle state management with StateFlow in Android is exposing Flow results to the UI for reliable data binding. This ensures consistent state updates and testable coroutine usage.

How do I test Kotlin coroutines and Flow operations?

Test Kotlin coroutines and Flow operations by implementing testing-friendly architectures with specific testing strategies. This ensures reliable concurrency, cancellation safety, and predictable error handling.

Does structured concurrency support parallel data source fetching in KMP?

Structured concurrency supports parallel data source fetching in KMP by coordinating multiple asynchronous requests safely. Results are combined and exposed via StateFlow for efficient UI consumption.

How do I handle errors and cancellation safely in Kotlin coroutines?

Handle errors and cancellation safely in Kotlin coroutines by applying structured concurrency principles and specific rollback strategies. This prevents memory leaks and ensures stable reactive data flows.