mirror of
https://github.com/biobulkbende/biobulkbende.org.git
synced 2024-12-27 05:15:25 +00:00
53 lines
2.3 KiB
JavaScript
53 lines
2.3 KiB
JavaScript
import { merge as higherOrder } from '../operators/merge';
|
|
export { merge as mergeStatic } from '../observable/merge';
|
|
/* tslint:enable:max-line-length */
|
|
/**
|
|
* Creates an output Observable which concurrently emits all values from every
|
|
* given input Observable.
|
|
*
|
|
* <span class="informal">Flattens multiple Observables together by blending
|
|
* their values into one Observable.</span>
|
|
*
|
|
* <img src="./img/merge.png" width="100%">
|
|
*
|
|
* `merge` subscribes to each given input Observable (either the source or an
|
|
* Observable given as argument), and simply forwards (without doing any
|
|
* transformation) all the values from all the input Observables to the output
|
|
* Observable. The output Observable only completes once all input Observables
|
|
* have completed. Any error delivered by an input Observable will be immediately
|
|
* emitted on the output Observable.
|
|
*
|
|
* @example <caption>Merge together two Observables: 1s interval and clicks</caption>
|
|
* var clicks = Rx.Observable.fromEvent(document, 'click');
|
|
* var timer = Rx.Observable.interval(1000);
|
|
* var clicksOrTimer = clicks.merge(timer);
|
|
* clicksOrTimer.subscribe(x => console.log(x));
|
|
*
|
|
* @example <caption>Merge together 3 Observables, but only 2 run concurrently</caption>
|
|
* var timer1 = Rx.Observable.interval(1000).take(10);
|
|
* var timer2 = Rx.Observable.interval(2000).take(6);
|
|
* var timer3 = Rx.Observable.interval(500).take(10);
|
|
* var concurrent = 2; // the argument
|
|
* var merged = timer1.merge(timer2, timer3, concurrent);
|
|
* merged.subscribe(x => console.log(x));
|
|
*
|
|
* @see {@link mergeAll}
|
|
* @see {@link mergeMap}
|
|
* @see {@link mergeMapTo}
|
|
* @see {@link mergeScan}
|
|
*
|
|
* @param {ObservableInput} other An input Observable to merge with the source
|
|
* Observable. More than one input Observables may be given as argument.
|
|
* @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
|
|
* Observables being subscribed to concurrently.
|
|
* @param {Scheduler} [scheduler=null] The IScheduler to use for managing
|
|
* concurrency of input Observables.
|
|
* @return {Observable} An Observable that emits items that are the result of
|
|
* every input Observable.
|
|
* @method merge
|
|
* @owner Observable
|
|
*/
|
|
export function merge(...observables) {
|
|
return higherOrder(...observables)(this);
|
|
}
|
|
//# sourceMappingURL=merge.js.map
|