我目前正在为当前项目选择RxJava 1.x或2.x.
我基本上需要$ PATH=/usr/local/bin:/usr/bin:/bin sanitize_PATH
PATH=/usr/local/bin:/usr/bin:/bin
$ PATH=:/usr/local/bin:/usr/bin:/bin sanitize_PATH
dropping from PATH: ''
PATH=/usr/local/bin:/usr/bin:/bin
$ PATH=/usr/local/bin:/usr/bin:/bin: sanitize_PATH
dropping from PATH: ''
PATH=/usr/local/bin:/usr/bin:/bin
$ PATH=/usr/local/bin:/usr/bin:/bin: sanitize_PATH
dropping from PATH: ''
PATH=/usr/local/bin:/usr/bin:/bin
$ PATH=.:bin:/usr/local/bin:/usr/bin:/bin sanitize_PATH
dropping from PATH: '.'
dropping from PATH: 'bin'
PATH=/usr/local/bin:/usr/bin:/bin
$ PATH=/usr/local/bin::/usr/bin:/bin sanitize_PATH
dropping from PATH: ''
PATH=/usr/local/bin:/usr/bin:/bin
背压策略PublishSubject
。
我想选择RxJava 2.x,但我不能完全理解如何将背压策略应用于onBackpressureLatest()
,因为它继承自PublishSubject
而不是Observable
{1}}。
您能告诉我如何在RxJava 2.x中创建Flowable
背压策略PublishSubject
吗?
答案 0 :(得分:14)
在2.x中,背压被移动到基本类型Flowable及其热门合作伙伴PublishProcessor,ReplayProcessor等。
PublishProcessor<Integer> pp = PublishProcessor.create();
Flowable<Integer> out = pp.onBackpressureLatest();
答案 1 :(得分:0)
我在某些时候使用过这样的东西:
Subject<Object> emitterSubject = PublishSubject.<Object>create().toSerialized();
emitterSubject.toFlowable(BackpressureStrategy.LATEST)