问题描述
我目前正在为我当前的项目选择 RxJava 1.x 或 2.x.
I am currently choosing between RxJava 1.x or 2.x for my current project.
我基本上需要一个带有背压策略onBackpressureLatest()
的PublishSubject
.
I basically need a PublishSubject
with a backpressure strategy onBackpressureLatest()
.
我想选择 RxJava 2.x,但我不太明白如何将背压策略应用于 PublishSubject
,因为它继承自 Observable
而不是来自 Flowable
.
I want to choose RxJava 2.x, but i can't quite get my head around on how to apply a backpressure strategy to a PublishSubject
, as it inherits from Observable
and not from Flowable
.
您能告诉我如何在 RxJava 2.x 中使用 onBackpressureLatest()
背压策略创建 PublishSubject
吗?
Could you please tell me how to create a PublishSubject
with a onBackpressureLatest()
backpressure strategy in RxJava 2.x ?
推荐答案
在 2.x 中,背压移至基本类型 Flowable 及其热门合作伙伴 PublishProcessor、ReplayProcessor 等.
In 2.x the backpressure was moved to the base type Flowable and its hot partners PublishProcessor, ReplayProcessor etc.
PublishProcessor<Integer> pp = PublishProcessor.create();
Flowable<Integer> out = pp.onBackpressureLatest();
这篇关于RxJava 2.x 中带有背压的 PublishSubject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!