kotlin-flows

Identify Kotlin Flow patterns for cold and hot streams in Android and Multiplatform projects.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps Kotlin developers select and use Flow, StateFlow, SharedFlow, and Channel correctly across Android and Kotlin Multiplatform projects to ensure correct lifecycle handling, type safety, and clean architecture.

Core Features & Use Cases

  • Guidance on choosing Flow types (Flow, StateFlow, SharedFlow, Channel) for data streams, UI state, and events.
  • Lifecycle-safe collection patterns for Compose and non-Compose apps, including repeatOnLifecycle and collectAsStateWithLifecycle equivalents.
  • Channel migration guidance with risk assessment and trade-offs between ensured delivery and potential missed emissions.
  • Operator and pattern recommendations: map, flatMapLatest, catch, retry, stateIn, shareIn, event handling, and avoiding side-effects inside transforms.
  • Testing approaches for Flow-based architectures using Turbine or similar.

Quick Start

Identify which Flow type fits a given UI scenario and apply the recommended patterns to migrate channels, ensure lifecycle-safe collection, and implement correct event handling.

Frequently Asked Questions about kotlin-flows

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

FAQPage Schema
How do I choose between StateFlow and SharedFlow for Kotlin UI state management?

Choose StateFlow for stateful UI requiring a single latest value, and SharedFlow for broadcasting events to multiple collectors. This ensures correct lifecycle handling and clean architecture in Kotlin Multiplatform and Android applications.

What is the best way to collect Kotlin Flows safely across Android lifecycle changes?

Use lifecycle-safe collection patterns like repeatOnLifecycle in Android to ensure Flow collection only happens when the lifecycle is active. This prevents hidden side effects and improper lifecycle handling during UI state management.

How do I migrate Channels to Kotlin Flows for event handling without missing emissions?

Migrate Channels to SharedFlow by evaluating trade-offs between ensured delivery and potential missed emissions. Assess event handling requirements to select the correct operator and avoid hidden side effects inside transforms.

Which Kotlin Flow operators should I use to avoid side effects in data streams?

Use operators like flatMapLatest, catch, and retry to manage data streams while avoiding side effects inside transforms. Selecting correct operators ensures clean error handling and prevents hidden behaviors in Kotlin coroutines.

How do I test Kotlin Flows and StateFlow architectures in Android applications?

Test Flow-based architectures using Turbine to verify cold and hot streams. Apply testing approaches to validate StateFlow, SharedFlow, and Channel event handling without blocking coroutines in Android and Multiplatform projects.

When should I use cold Flow versus hot SharedFlow in Kotlin Multiplatform projects?

Use cold Flow for on-demand data streams that restart per collector, and hot SharedFlow for sharing emissions across multiple collectors. Selecting the correct type ensures proper stateful UI and lifecycle-safe collection in Kotlin Multiplatform.