Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
You can make RxJava2 and Reactor 3 types interact without a single external library.
In the first two examples we will adapt from
Flowable, which implements
This is straightforward as both libraries provide a factory method to do that conversion from
Publisher. The checker below runs the two opposite conversions in one go:
The next two examples are a little trickier: we need to adapt between
but the later doesn't implement
In the first case, you can transform any publisher to
In the second case, you have to first transform the
Observable into a
forces you to define a strategy to deal with backpressure (RxJava 2
Next, let's try to transform a
Mono to a RxJava
Single, and vice-versa. You can
simply call the
firstOrError method from
Observable. For the other way around, you'll
once again need to transform the
Single into a
Finally, you can easily transform a
Mono to a Java 8
CompletableFuture and vice-versa.
Notice how these conversion methods all begin with
from (when converting an external type
to a Reactor one) and
to (when converting a Reactor type to an external one).