Rxjava To Coroutines Migration
Guide and execute the migration of asynchronous code from RxJava to Kotlin Coroutines...
Install
npx skills add new-silvermoon/awesome-android-agent-skills --skill rxjava-to-coroutines-migration -g -a claude-code -y- Repository
- new-silvermoon/awesome-android-agent-skills998
- Category
- Mobile
- Updated
- 3mo ago
- License
- Apache-2.0
- Context cost
- Lightabout 1,142 tokens
- Runs scripts
- No, instructions only
What it does
Guide and execute the migration of asynchronous code from RxJava to Kotlin Coroutines and Flow. Use this skill when a user asks to convert RxJava (Observables, Singles, Completables, Subjects) to Coroutines (suspend functions, Flows, StateFlows).
RxJava to Kotlin Coroutines Migration Skill
A specialized skill designed to safely and idiomatically refactor Android or Kotlin codebases from RxJava to Kotlin Coroutines and Flow.
Migration Mapping Guide
When migrating RxJava components to Kotlin Coroutines, use the following standard mappings:
1. Base Types
Single<T>->suspend fun ...(): T- A single asynchronous value.
Maybe<T>->suspend fun ...(): T?- A single asynchronous value that might not exist.
Completable->suspend fun ...()- An asynchronous operation that completes without a value.
Observable<T>->Flow<T>- A cold stream of values.
Flowable<T>->Flow<T>- Coroutines Flow natively handles backpressure.
2. Subjects to Hot Flows
PublishSubject<T>->MutableSharedFlow<T>- Broadcasts events to multiple subscribers. Use
MutableSharedFlow(extraBufferCapacity = ...)if buffering is needed.
- Broadcasts events to multiple subscribers. Use
BehaviorSubject<T>->MutableStateFlow<T>- Holds state and emits the current/latest value to new subscribers. Requires an initial value.
ReplaySubject<T>->MutableSharedFlow<T>(replay = N)- Replays the last N emitted values to new subscribers.
3. Schedulers to Dispatchers
Schedulers.io()->Dispatchers.IOSchedulers.computation()->Dispatchers.DefaultAndroidSchedulers.mainThread()->Dispatchers.Main- Context Switching:
subscribeOnandobserveOnare typically replaced bywithContext(Dispatcher)orflowOn(Dispatcher)for Flows.
