function
stable
Creates an output Observable which concurrently emits all values from every given input Observable.
merge<T, R>(...observables: Array<ObservableInput<any> | SchedulerLike | number>): Observable<R>
observables | Input Observables to merge together. |
Observable<R>
: an Observable that emits items that are the result of every input Observable.
Flattens multiple Observables together by blending their values into one Observable.
merge
subscribes to each given input Observable (as arguments), 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.
import { merge, fromEvent, interval } from 'rxjs'; const clicks = fromEvent(document, 'click'); const timer = interval(1000); const clicksOrTimer = merge(clicks, timer); clicksOrTimer.subscribe(x => console.log(x)); // Results in the following: // timer will emit ascending values, one every second(1000ms) to console // clicks logs MouseEvents to console everytime the "document" is clicked // Since the two streams are merged you see these happening // as they occur.
import { merge, interval } from 'rxjs'; import { take } from 'rxjs/operators'; const timer1 = interval(1000).pipe(take(10)); const timer2 = interval(2000).pipe(take(6)); const timer3 = interval(500).pipe(take(10)); const concurrent = 2; // the argument const merged = merge(timer1, timer2, timer3, concurrent); merged.subscribe(x => console.log(x)); // Results in the following: // - First timer1 and timer2 will run concurrently // - timer1 will emit a value every 1000ms for 10 iterations // - timer2 will emit a value every 2000ms for 6 iterations // - after timer1 hits it's max iteration, timer2 will // continue, and timer3 will start to run concurrently with timer2 // - when timer2 hits it's max iteration it terminates, and // timer3 will continue to emit a value every 500ms until it is complete
merge(v1: ObservableInput<T>, scheduler: SchedulerLike): Observable<T>
v1 | Type: |
scheduler | Type: |
Observable<T>
merge(v1: ObservableInput<T>, concurrent: number, scheduler: SchedulerLike): Observable<T>
v1 | Type: |
concurrent | Type: |
scheduler | Type: |
Observable<T>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, scheduler: SchedulerLike): Observable<T | T2>
v1 | Type: |
v2 | Type: |
scheduler | Type: |
Observable<T | T2>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, concurrent: number, scheduler: SchedulerLike): Observable<T | T2>
v1 | Type: |
v2 | Type: |
concurrent | Type: |
scheduler | Type: |
Observable<T | T2>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, scheduler: SchedulerLike): Observable<T | T2 | T3>
v1 | Type: |
v2 | Type: |
v3 | Type: |
scheduler | Type: |
Observable<T | T2 | T3>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, concurrent: number, scheduler: SchedulerLike): Observable<T | T2 | T3>
v1 | Type: |
v2 | Type: |
v3 | Type: |
concurrent | Type: |
scheduler | Type: |
Observable<T | T2 | T3>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4>
v1 | Type: |
v2 | Type: |
v3 | Type: |
v4 | Type: |
scheduler | Type: |
Observable<T | T2 | T3 | T4>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, concurrent: number, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4>
v1 | Type: |
v2 | Type: |
v3 | Type: |
v4 | Type: |
concurrent | Type: |
scheduler | Type: |
Observable<T | T2 | T3 | T4>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5>
v1 | Type: |
v2 | Type: |
v3 | Type: |
v4 | Type: |
v5 | Type: |
scheduler | Type: |
Observable<T | T2 | T3 | T4 | T5>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, concurrent: number, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5>
v1 | Type: |
v2 | Type: |
v3 | Type: |
v4 | Type: |
v5 | Type: |
concurrent | Type: |
scheduler | Type: |
Observable<T | T2 | T3 | T4 | T5>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5 | T6>
v1 | Type: |
v2 | Type: |
v3 | Type: |
v4 | Type: |
v5 | Type: |
v6 | Type: |
scheduler | Type: |
Observable<T | T2 | T3 | T4 | T5 | T6>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>, concurrent: number, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5 | T6>
v1 | Type: |
v2 | Type: |
v3 | Type: |
v4 | Type: |
v5 | Type: |
v6 | Type: |
concurrent | Type: |
scheduler | Type: |
Observable<T | T2 | T3 | T4 | T5 | T6>
merge(v1: ObservableInput<T>): Observable<T>
v1 | Type: |
Observable<T>
merge(v1: ObservableInput<T>, concurrent?: number): Observable<T>
v1 | Type: |
concurrent | Optional. Default is Type: |
Observable<T>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>): Observable<T | T2>
v1 | Type: |
v2 | Type: |
Observable<T | T2>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, concurrent?: number): Observable<T | T2>
v1 | Type: |
v2 | Type: |
concurrent | Optional. Default is Type: |
Observable<T | T2>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>): Observable<T | T2 | T3>
v1 | Type: |
v2 | Type: |
v3 | Type: |
Observable<T | T2 | T3>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, concurrent?: number): Observable<T | T2 | T3>
v1 | Type: |
v2 | Type: |
v3 | Type: |
concurrent | Optional. Default is Type: |
Observable<T | T2 | T3>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>): Observable<T | T2 | T3 | T4>
v1 | Type: |
v2 | Type: |
v3 | Type: |
v4 | Type: |
Observable<T | T2 | T3 | T4>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, concurrent?: number): Observable<T | T2 | T3 | T4>
v1 | Type: |
v2 | Type: |
v3 | Type: |
v4 | Type: |
concurrent | Optional. Default is Type: |
Observable<T | T2 | T3 | T4>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>): Observable<T | T2 | T3 | T4 | T5>
v1 | Type: |
v2 | Type: |
v3 | Type: |
v4 | Type: |
v5 | Type: |
Observable<T | T2 | T3 | T4 | T5>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, concurrent?: number): Observable<T | T2 | T3 | T4 | T5>
v1 | Type: |
v2 | Type: |
v3 | Type: |
v4 | Type: |
v5 | Type: |
concurrent | Optional. Default is Type: |
Observable<T | T2 | T3 | T4 | T5>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>): Observable<T | T2 | T3 | T4 | T5 | T6>
v1 | Type: |
v2 | Type: |
v3 | Type: |
v4 | Type: |
v5 | Type: |
v6 | Type: |
Observable<T | T2 | T3 | T4 | T5 | T6>
merge(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>, concurrent?: number): Observable<T | T2 | T3 | T4 | T5 | T6>
v1 | Type: |
v2 | Type: |
v3 | Type: |
v4 | Type: |
v5 | Type: |
v6 | Type: |
concurrent | Optional. Default is Type: |
Observable<T | T2 | T3 | T4 | T5 | T6>
merge(...observables: (ObservableInput<T> | number)[]): Observable<T>
observables | Type: |
Observable<T>
merge(...observables: (ObservableInput<T> | SchedulerLike | number)[]): Observable<T>
observables | Type: |
Observable<T>
merge(...observables: (ObservableInput<any> | number)[]): Observable<R>
observables | Type: |
Observable<R>
merge(...observables: (ObservableInput<any> | SchedulerLike | number)[]): Observable<R>
observables | Type: |
Observable<R>
© 2015–2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/index/function/merge