How to create an Rx (RxJS) stream that can be switched between single-item and batch-mode?
问题 I have an Rx stream that is an outgoing change feed from a particular component. Occasionally I want to be able to enter a batch mode on the stream so that items passed to onNext accumulate and are passed on only when the batch mode is exited. Normally I'll pass single items through the stream: stream.onNext(1); stream.onNext(2); There is a 1-to-1 mapping between the items passed to onNext and the items received in the subscribe , so the previous snippet results in two calls to subscribe with