RxJava 1 -> RxJava 2 (Understanding the Changes)
Article Summary
RxJava 2 was a complete rewrite with breaking APIs. If you're still on version 1, here's what changed and why it matters.
Kaushik Gopal breaks down the RxJava 1 to 2 migration in this technical guide. The rewrite wasn't arbitrary: RxJava 2 now implements the Reactive Streams specification, making interop between reactive libraries much easier.
Key Takeaways
- Flowable replaces Observable as your default: it's Observable plus backpressure handling
- Reactive Streams spec has just 4 interfaces: Publisher, Subscriber, Subscription, Processor
- Package changed from rx to io.reactivex, gradle dependencies need '2' suffix
- Observable still exists but for specialized use cases only
- Don't run RxJava 1 and 2 simultaneously: backpressure behavior differs drastically
RxJava 2's adoption of Reactive Streams standardization means better library interop, but requires understanding the Flowable vs Observable distinction.
About This Article
RxJava 1 and RxJava 2 handle backpressure differently, which creates real problems when you try to use both in the same project. Developers end up having to explicitly qualify Observable imports with package names (rx.Observable vs io.reactivex.Observable) just to keep them straight.
Kaushik Gopal suggests migrating all your code at once instead of doing it gradually. This avoids the messy period where you have to remember which version behaves which way.
RxJava 2 follows the Reactive Streams specification, which means it works well with other reactive libraries that implement the same 4-interface spec. Publisher, Subscriber, Subscription, and Processor are the interfaces involved.