rxjava-migration

Migrate RxJava code to Kotlin coroutines and flows with explicit type and operator mappings.

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/chmonya-inc/dnd-manager --skill rxjava-migration-chmonya-inc
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rxjava-migration
Source: https://github.com/chmonya-inc/dnd-manager/tree/main/.agents/skills/rxjava-migration
Command: npx skills add https://github.com/chmonya-inc/dnd-manager --skill rxjava-migration-chmonya-inc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Migrating RxJava code to Kotlin coroutines and flows is error-prone: types like BehaviorSubject have ambiguous mappings, retry semantics differ between the two models, and hot versus cold stream behavior can silently change. This Skill provides a structured, incremental migration process that classifies code complexity first and forces explicit decisions before any code is rewritten. ## Core Features & Use Cases - Complexity Assessment: Classifies RxJava chains as Simple or Complex based on operator count, schedulers, error recovery, and backpressure, so trivial cases map directly while risky ones trigger user prompts. - Type, Scheduler, and Operator Mapping: Provides explicit tables mapping Single, Maybe, Completable, Subject variants, and Schedulers to suspend functions, Flow, StateFlow, SharedFlow, and CoroutineDispatchers, plus a full operator reference in migration-map.md. - Incremental Interop Strategy: Uses kotlinx-coroutines-rx3 bridges (await, asFlow, asObservable) at layer boundaries so migration proceeds leaf-first from data sources up to ViewModels. - Use Case: A developer asks to migrate a repository class using flatMap, retryWhen, and a BehaviorSubject. The Skill flags it as Complex, asks about retry policy and StateFlow versus SharedFlow semantics, then produces correct Flow code using retryWhen and MutableStateFlow. ## Quick Start Migrate this RxJava repository class to Kotlin coroutines and flows, asking me about any ambiguous mappings before writing code.

Frequently Asked Questions about rxjava-migration

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

FAQPage Schema
How do I migrate RxJava to Kotlin coroutines and Flow?▼

Migrate incrementally from leaf nodes upward: convert data sources first using kotlinx-coroutines-rx3 bridges like await() and asFlow(), then repositories, use cases, and ViewModels. Map Single to suspend functions, Observable to Flow, and Subjects to SharedFlow or StateFlow.

What is the Flow equivalent of RxJava Single, Maybe, and Completable?▼

Single maps to a suspend function returning T, Maybe maps to a suspend function returning a nullable T, and Completable maps to a suspend function returning Unit. Observable and Flowable both map to Flow, with Flowable requiring explicit backpressure handling.

Should BehaviorSubject become StateFlow or SharedFlow?▼

Use MutableStateFlow when you always have an initial value and need .value access. Use MutableSharedFlow with replay = 1 when the stream may start empty and you do not need synchronous value access. The choice depends on your semantics, so confirm before migrating.

How do I convert RxJava retryWhen to Kotlin Flow?▼

Use Flow's retryWhen { cause, attempt -> } operator, where cause is the Throwable and attempt is the zero-based attempt index. Do not use retry(n) with a predicate expecting an index, since that lambda receives the Throwable, not a count.

Why is switchMap to flatMapLatest dangerous for write operations?▼

flatMapLatest cancels the previous inner stream when a new upstream value arrives, which can abort in-flight write operations mid-transaction. It is safe for reads like search queries, but confirm cancellation safety with the developer before using it for writes.

Can I mix RxJava and coroutines during an incremental migration?▼

Yes, using the kotlinx-coroutines-rx3 library with bridges like asFlow(), await(), and asObservable(). Keep interop strictly at layer boundaries, never mix both models within the same function body, and remove bridges after each layer is fully migrated.