kotlin-coroutines-flows

Design Kotlin coroutine and Flow concurrency patterns for asynchronous code.

Updated Mar 27, 2026
One-click install
npx skills add https://github.com/emiled16/close-to-me --skill kotlin-coroutines-flows-emiled16
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-coroutines-flows
Source: https://github.com/emiled16/close-to-me/tree/main/.codex/skills/kotlin-coroutines-flows
Command: npx skills add https://github.com/emiled16/close-to-me --skill kotlin-coroutines-flows-emiled16

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps Kotlin developers write async code that stays correct under cancellation, concurrent loading, UI state updates, and cross-platform execution.

Core Features & Use Cases

  • Structured concurrency patterns for launching work in the right scope instead of relying on global tasks.
  • Flow, StateFlow, and SharedFlow guidance for reactive state, one-time effects, and stream composition.
  • Dispatcher selection, retry handling, cancellation safety, and testing with deterministic coroutine test tools.
  • Use it to implement view models, repository streams, debounced search, parallel data loading, and KMP-friendly async logic.

Quick Start

Ask for a coroutine and Flow implementation pattern for your Kotlin feature, including scope choice, state handling, cancellation, and tests.

Frequently Asked Questions about kotlin-coroutines-flows

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

FAQPage Schema
How do I implement structured concurrency in Kotlin coroutines for Android?

Structured concurrency requires launching Kotlin coroutines in specific scopes rather than global ones. This pattern ties async tasks to Android or KMP lifecycles, ensuring automatic cancellation and preventing memory leaks when views unload.

What is the best way to manage reactive UI state with StateFlow and SharedFlow?

Use StateFlow for holding persistent UI state and SharedFlow for emitting one-time effects in Kotlin view models. This separation ensures UI components observe state changes reliably while handling transient events without redundant emissions.

How do I test Kotlin coroutine flows deterministically using Turbine?

Test Kotlin coroutine flows using Turbine to intercept and assert stream emissions deterministically. This tool allows you to validate StateFlow updates and cooperative cancellation behavior without relying on real-time dispatcher delays.

Does Kotlin Multiplatform support shared coroutine dispatcher logic for parallel loading?

Kotlin Multiplatform supports shared coroutine dispatcher logic for parallel loading by injecting platform-specific dispatchers. This enables concurrent data fetching and repository stream composition while maintaining strict cancellation safety across targets.

Why does my Kotlin coroutine cancel but leave my Flow background task running?

Your Kotlin coroutine cancels but leaves the Flow running because the collection lacks structured concurrency scoping. Ensure the Flow is collected within a lifecycle-bound coroutine scope to enforce cooperative cancellation when the parent job aborts.