kotlin-coroutines-flows

Implement Kotlin Coroutines and Flow patterns for Android and Kotlin Multiplatform.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Android and Kotlin Multiplatform apps often struggle with managing asynchronous work, UI responsiveness, and testability when using Kotlin Coroutines and Flow. This guide centralizes proven structured concurrency patterns, Flow usage, and robust testing strategies to streamline development and reliability.

Core Features & Use Cases

  • Structured concurrency patterns across Android ViewModels and shared Kotlin code to ensure proper lifecycle management and cancellation.
  • Flow operators, StateFlow, and SharedFlow for modeling reactive UI state and events with clear data pipelines.
  • Testing techniques for coroutines and flows, including fake repositories, test dispatchers, and flow testing utilities.

Quick Start

Start by identifying a UI feature that relies on asynchronous streams and refactor it to use a ViewModel with a StateFlow and a few simple flows, then add tests to validate proper state transitions.

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 streams with Kotlin Coroutines and Flow in Android ViewModels?

To manage asynchronous streams with Kotlin Coroutines and Flow in Android ViewModels, apply structured concurrency patterns using StateFlow and SharedFlow. This ensures proper lifecycle management, responsive UIs, and clear data pipelines for reactive state and events.

What is the best way to test Kotlin Coroutines and Flow across shared Kotlin Multiplatform code?

The best way to test Kotlin Coroutines and Flow in Kotlin Multiplatform is by using test dispatchers, fake repositories, and standard flow testing utilities. This approach validates state transitions and ensures robust testing across shared Kotlin code and Android scopes.

How do I handle cancellation and errors in Kotlin Flow operators for responsive UIs?

To handle cancellation and errors in Kotlin Flow operators for responsive UIs, utilize structured concurrency patterns that enforce proper lifecycle management. Applying specific Flow error handling and cancellation operators ensures your app remains stable during asynchronous state updates.

Does this Kotlin Coroutines and Flow guide support Kotlin Multiplatform projects?

Yes, this Kotlin Coroutines and Flow guide fully supports Kotlin Multiplatform (KMP) projects. It provides structured concurrency patterns and testing strategies applicable to both Android ViewModel scopes and shared Kotlin code across multiple platforms.

When do I need StateFlow versus SharedFlow for modeling reactive UI state?

You need StateFlow for modeling reactive UI state when you require a single source of truth with value retention, and SharedFlow for broadcasting events to multiple consumers. Both are covered for building clear data pipelines in responsive apps.