简体   繁体   中英

RxJava 2.0 - How to convert Observable to Publisher

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM