SKILL

kotlin-coroutines-flows

Android および KMP 向けの Kotlin コルーチンと Flow パターン — 構造化並行性、Flow オペレーター、StateFlow、エラーハンドリング、テスト。

Original · translation did not pass checks

Target: Mobile development. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original Japanese text

Topics in the source

  • Kotlin コルーチン & Flow
  • アクティベートするタイミング
  • 構造化並行性
  • スコープ階層
  • 並列分解
  • SupervisorScope
  • Flow パターン
  • コールドフロー — ワンショットからストリームへの変換

Android および Kotlin Multiplatform プロジェクトにおける構造化並行性、Flow ベースのリアクティブストリーム、コルーチンテストのパターン。 Kotlin コルーチンで非同期コードを書く リアクティブデータに Flow、StateFlow、または SharedFlow を使用する 並行操作を処理する(並列読み込み、デバウンス、リトライ) コルーチンと Flow をテストする コルーチンスコープとキャンセルを管理する 常に構造化並行性を使用してください — GlobalScope は絶対に使わない: 並列作業には coroutineScope + async を使用: 子の失敗が兄弟をキャンセルしてはならない場合は supervisorScope を使用: WhileSubscribed(5000) は最後のサブスクライバーが離れてから 5 秒間アップストリームをアクティブに保ちます — 設定変更を再起動なしに生き延びます。 KMP では Dispatchers.Default と Dispatchers.Main(すべてのプラットフォームで利用可能)を使用してください。Dispatchers.IO は JVM/Android のみです — 他のプラットフォームでは Dispatchers.Default を使用するか DI で提供してください。 長時間実行されるループはキャンセルを確認する必要があります: GlobalScope の使用 — コルーチンがリークし、構造化キャンセルがない スコープなしで init {} 内で Flow をコレクトする — viewModelScope.launch を使用 ミュータブルコレクションで MutableStateFlow を使用する — 常にイミュータブルコピーを使用: state.update { it.copy(list = it.list + newItem) } CancellationException をキャッチする — 適切なキャンセルのために伝播させる コレクトするために flowOn(Dispatchers.Main) を使用する — コレクションディスパッチャーは呼び出し元のディスパッチャー remember なしで @Composable 内に Flow を作成する — 再コンポジションのたびにフローが再作成される スキル: compose-multiplatform-patterns で Flow の UI 消費を参照。 スキル: android-clean-architecture でレイヤーにおけるコルーチンの役割を参照。

Source repository
affaan-m/ECC
Source file
docs/ja-JP/skills/kotlin-coroutines-flows/SKILL.md
Fixed revision
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Read the complete original documentation ↗

Requirements

  • Only the author’s Skill metadata is included. Read the full instructions to check dependencies, licensing and conditions of use.

A small first task

先阅读原作者说明,再决定是否在自己的 AI 工具中使用。

Instructions for your AI tool

Author documentation is not live verification by this site. Without evidence, we do not mark a resource as compatible, safe or free.

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T14:01:49.375Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.