coroutines-flow

Model cold asynchronous streams with Kotlin Flow operators and cancellation.

Updated Apr 8, 2026
One-click install
npx skills add https://github.com/ClankerGuru/opsx --skill coroutines-flow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: coroutines-flow
Source: https://github.com/ClankerGuru/opsx/tree/main/cli/src/main/resources/content/skills/coroutines-flow
Command: npx skills add https://github.com/ClankerGuru/opsx --skill coroutines-flow

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Flow-based programming patterns solve the challenge of modeling asynchronous streams in Kotlin, providing a principled way to build composable, cancellation-friendly pipelines.

Core Features & Use Cases

  • Learn to construct Flow pipelines with flow { }, callbackFlow, and channelFlow to handle producers and consumers.
  • Use common operators such as map, filter, debounce, transform, flatMapMerge, and flowOn, along with lifecycle hooks like onStart, onEach, onCompletion, and catch/retry.
  • Compare Flow and Sequence, reason about backpressure, cancellation, testing with runTest and turbine, and practical streaming scenarios (debounced streams, data processing, and I/O-bound pipelines).

Quick Start

Try a simple Flow example by creating a flow { emit(1); emit(2) } and collecting it to observe the emitted values.

Frequently Asked Questions about coroutines-flow

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

FAQPage Schema
How do I model cold asynchronous streams with Kotlin coroutines?

Cold asynchronous streams in Kotlin are modeled using Flow, allowing you to build composable, cancellation-friendly pipelines. You construct streams with flow { }, callbackFlow, or channelFlow to handle producers and emit values sequentially to consumers.

What is the best way to handle backpressure and cancellation in Kotlin Flow pipelines?

Backpressure and cancellation in Kotlin Flow pipelines are handled using backpressure-aware operators and lifecycle hooks. You apply operators like flowOn, debounce, and onCompletion to manage downstream consumption rates and ensure coroutine cancellation propagates correctly.

How do I apply operators like flatMapMerge and transform to Kotlin streams?

Operators like flatMapMerge and transform apply to Kotlin streams by composing sequential processing logic. You chain these operators on a Flow instance to map, filter, debounce, or merge concurrent streams while maintaining asynchronous execution.

Can I handle errors and retry logic in asynchronous Kotlin pipelines?

Errors and retry logic in asynchronous Kotlin pipelines are handled using Flow lifecycle hooks. You apply the catch and retry operators alongside onCompletion to intercept exceptions and re-trigger emissions without breaking the coroutine stream pipeline.

Does Kotlin Flow work with callback-based APIs?

Kotlin Flow integrates with callback-based APIs using callbackFlow. This builder bridges existing callback interfaces into a cold asynchronous stream, allowing you to suspend execution and safely emit values from external event producers.

How do I test Kotlin Flow streams and debounced transforms?

Kotlin Flow streams and debounced transforms are tested using runTest and turbine. These testing frameworks allow you to control virtual time, collect emissions, and verify lifecycle hook behaviors or backpressure logic without asynchronous delays.