RxJava 2.0 - How to convert Observable to Publisher

13,893

Use the following code:

Publisher publisher = observable.toFlowable(BackpressureStrategy.XXX);

As Observable does not implement backpressure, you need to select backpressure strategy when converting. See available choices here.

Or use Flowable instead of Observable in the first place. See here for details.

Share:
13,893

Related videos on Youtube

caioquirino
Author by

caioquirino

Updated on June 04, 2022

Comments

  • caioquirino
    caioquirino almost 2 years

    How to convert Observable to Publisher in RxJava version 2?

    In the first version we have the https://github.com/ReactiveX/RxJavaReactiveStreams project that do exactly what I need. But How can I do it in RxJava 2?

    • akarnokd
      akarnokd over 7 years
      Convert it to Flowable as it implements Publisher.