kotlin-coroutines-flows

Implement structured concurrency and Flow streams for Kotlin asynchronous code.

Updated Apr 2, 2026
One-click install
npx skills add https://github.com/richardnpaul/everything-vscode-copilot --skill kotlin-coroutines-flows-richardnpaul
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-coroutines-flows
Source: https://github.com/richardnpaul/everything-vscode-copilot/tree/main/.github/skills/kotlin-coroutines-flows
Command: npx skills add https://github.com/richardnpaul/everything-vscode-copilot --skill kotlin-coroutines-flows-richardnpaul

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Kotlin coroutines and Flow patterns help simplify asynchronous work, avoid nested callbacks, and enable reactive UI updates across Android and Kotlin Multiplatform projects.

Core Features & Use Cases

  • Structured concurrency with scopes like viewModelScope and coroutineScope to manage lifecycle and cancellation.
  • Flow-based data streams using Flow, StateFlow, and SharedFlow for reactive UI state and one-time events.
  • Testing patterns for coroutines and flows, including Turbine and test dispatchers, plus cancellation handling.

Quick Start

Create a ViewModel and expose a StateFlow that updates in response to repository data using viewModelScope.launch and flows.

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 StateFlow for reactive UI state in Android ViewModels?

Manage StateFlow for reactive UI state by exposing it from your ViewModel and updating it in response to repository data using viewModelScope.launch. This structured concurrency pattern ensures lifecycle-aware cancellation and seamless reactive UI updates.

What's the best way to test Kotlin coroutines and Flow streams?

The best way to test Kotlin coroutines and Flow streams is by using test dispatchers and Turbine. This approach provides structured testing patterns for asynchronous code, handling cancellation and verifying reactive emissions effectively.

When should I use SharedFlow versus StateFlow for one-time events?

Use SharedFlow for one-time UI events and StateFlow for representing reactive UI state. Both Flow-based streams simplify asynchronous work by avoiding nested callbacks and enabling structured concurrency across Android and Kotlin Multiplatform projects.

How do I handle cancellation and error handling in Kotlin Multiplatform coroutines?

Handle cancellation and errors in Kotlin Multiplatform coroutines by applying structured concurrency patterns using coroutineScope. This ensures concurrent operations across repositories and use cases are safely canceled and managed without leaking resources.

Does this Kotlin coroutines pattern support asynchronous UI data loads in Kotlin Multiplatform?

Yes, these Kotlin coroutines patterns support asynchronous UI data loads in Kotlin Multiplatform projects. They resolve asynchronous code complexity by providing structured concurrency scopes and Flow-based streams for reactive state management.