Yes, you can use zip to do what you want:
const input = Rx.Observable.from(["a", "b", "c", "d", "e"]); const signal = new Rx.Subject(); const output = Rx.Observable.zip(input, signal, (i, s) => i); output.subscribe(value => console.log(value)); signal.next(1); signal.next(1); signal.next(1);
.as-console-wrapper { max-height: 100% !important; top: 0; }
<script src="https://unpkg.com/rxjs/bundles/Rx.min.js"></script>
In fact, zip used as an example in this GitHub issue , which relates to buffering.
If you want to use the value emitted by the signal to determine how many buffered values โโshould be issued, you can do something like this:
const input = Rx.Observable.from(["a", "b", "c", "d", "e"]); const signal = new Rx.Subject(); const output = Rx.Observable.zip( input, signal.concatMap(count => Rx.Observable.range(0, count)), (i, s) => i ); output.subscribe(value => console.log(value)); signal.next(1); signal.next(2); signal.next(1);
.as-console-wrapper { max-height: 100% !important; top: 0; }
<script src="https://unpkg.com/rxjs/bundles/Rx.min.js"></script>
source share