我試圖用的反應背壓處理這一問題,以自己熟悉,特別是通過閱讀這篇維基:https://github.com/ReactiveX/RxJava/wiki/Backpressure爲什麼我們在這種情況下需要Publish和RefCount Rx操作符?
In the buffer paragraph,我們有這個更復雜的示例代碼:
// we have to multicast the original bursty Observable so we can use it
// both as our source and as the source for our buffer closing selector:
Observable<Integer> burstyMulticast = bursty.publish().refCount();
// burstyDebounced will be our buffer closing selector:
Observable<Integer> burstyDebounced = burstMulticast.debounce(10, TimeUnit.MILLISECONDS);
// and this, finally, is the Observable of buffers we're interested in:
Observable<List<Integer>> burstyBuffered = burstyMulticast.buffer(burstyDebounced);
如果我理解正確的話,我們通過爲緩衝區運算符生成一個去抖動信號流,有效地消除了突發源碼流。
但是,爲什麼我們需要在這裏使用發佈和refcount運算符?如果我們放棄它們會導致什麼問題?這些評論對我來說並不是很清楚,RxJava Observables是不是默認多播?