kotlin-coroutines-flows

Implement structured concurrency and Flow patterns for Kotlin Android and Multiplatform projects.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/luongldptit/move-ticket --skill kotlin-coroutines-flows-luongldptit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-coroutines-flows
Source: https://github.com/luongldptit/move-ticket/tree/main/.agent/skills/kotlin-coroutines-flows
Command: npx skills add https://github.com/luongldptit/move-ticket --skill kotlin-coroutines-flows-luongldptit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates the common pain points of writing unmaintainable, leaky asynchronous code in Kotlin Android and Kotlin Multiplatform (KMP) projects, resolving issues like unstructured coroutine scopes, unhandled Flow errors, and flaky reactive UI state.

Core Features & Use Cases

  • Structured Concurrency Patterns: Provides best-practice scope hierarchy, parallel task decomposition with async/await, and supervisor scopes for independent concurrent operations to prevent coroutine leaks.
  • Flow Reactive Stream Management: Includes ready-to-use patterns for StateFlow, SharedFlow, common Flow operators (debounce, retry, combine), and error handling for reliable UI state and one-time event delivery.
  • Coroutine Testing & Safety: Offers tested patterns for validating Flow emissions and coroutine behavior with Turbine and TestDispatcher, plus a list of anti-patterns to avoid common pitfalls.
  • Use Case: For example, if you are building a KMP dashboard app that loads data from 3 independent APIs, this Skill gives you the exact pattern to run parallel requests safely without cancelling sibling tasks if one fails.

Quick Start

Use the kotlin-coroutines-flows skill to implement a parallel data loading pattern for your dashboard ViewModel that fetches user items, stats, and profile concurrently without cancelling sibling requests if one fails.

Frequently Asked Questions about kotlin-coroutines-flows

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

FAQPage Schema
How do I run parallel API requests in Kotlin coroutines without cancelling sibling tasks if one fails?

To run parallel Kotlin coroutine requests safely without cancelling siblings, use supervisorScope to launch independent concurrent operations, ensuring one failure does not cancel sibling tasks. This structured concurrency pattern prevents unhandled failures and coroutine leaks in parallel data loading.

What is the best way to manage UI state with StateFlow in Kotlin Multiplatform?

Managing UI state with StateFlow in Kotlin Multiplatform requires applying Flow reactive stream patterns to expose and update state safely. This approach eliminates flaky reactive UI state by ensuring reliable emission delivery and proper error handling for asynchronous data streams.

How do I implement debounced search input and exponential backoff retry in Kotlin Flows?

Implementing debounced search and exponential backoff retry in Kotlin Flows involves applying built-in Flow operators like debounce and retry to handle reactive stream events safely. These operators manage rapid input sequences and transient network failures without leaking coroutine scopes.

Why do my Kotlin coroutines leak when using GlobalScope, and how do I fix unstructured concurrency?

Kotlin coroutines leak when using GlobalScope because it bypasses structured concurrency, leaving asynchronous operations unmanaged. Fix unstructured concurrency by implementing a proper coroutine scope hierarchy that enforces cancellation safety and prevents unhandled coroutine failures.

How do I test Kotlin Flow emissions and coroutine behavior with Turbine and TestDispatcher?

To test Kotlin Flow emissions and coroutine behavior, apply tested patterns using Turbine to validate Flow streams and TestDispatcher to control virtual time. This approach ensures reliable async code architecture by verifying reactive sequences and timing-dependent operations.

Can I use Kotlin coroutines and Flows for both Android and Kotlin Multiplatform projects?

Yes, you can use Kotlin coroutines and Flows for both Android and Kotlin Multiplatform projects to enforce structured concurrency and reactive stream patterns. This cross-platform compatibility ensures safe async code architecture, avoiding GlobalScope leaks and unhandled failures across shared logic.