我正在尝试熟悉反应式背压处理的问题,特别是通过阅读此 wiki:https ://github.com/ReactiveX/RxJava/wiki/Backpressure
在缓冲区段落中,我们有这个更复杂的示例代码:
// 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);
如果我理解正确,我们通过为缓冲区操作符生成去抖信号流来有效地去抖突发源流。
但是为什么我们需要在这里使用 publish 和 refcount 操作符呢?如果我们只是丢弃它们会导致什么问题?评论并没有让我更清楚,RxJava Observables 不是默认支持多播吗?