diff --git a/packages/rxjs/src/internal/observable/concat.ts b/packages/rxjs/src/internal/observable/concat.ts index 4bda7f68df..ab1bec0b36 100644 --- a/packages/rxjs/src/internal/observable/concat.ts +++ b/packages/rxjs/src/internal/observable/concat.ts @@ -20,9 +20,11 @@ export function concat( * ![](concat.png) * * `concat` joins multiple Observables together, by subscribing to them one at a time and - * merging their results into the output Observable. You can pass either an array of - * Observables, or put them directly as arguments. Passing an empty array will result - * in Observable that completes immediately. + * merging their results into the output Observable. Pass each Observable directly + * as an argument. If you already have an array of Observables, spread the array into + * `concat` so each Observable is passed as its own input. Passing the array itself + * will emit the Observables in the array instead of subscribing to them sequentially. + * Passing no Observables will result in an Observable that completes immediately. * * `concat` will subscribe to first input Observable and emit all its values, without * changing or affecting them in any way. When that Observable completes, it will @@ -82,6 +84,23 @@ export function concat( * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9 * ``` * + * Concatenate an array of Observables + * + * ```ts + * import { interval, take, concat } from 'rxjs'; + * + * const timer1 = interval(1000).pipe(take(10)); + * const timer2 = interval(2000).pipe(take(6)); + * const timer3 = interval(500).pipe(take(10)); + * + * const timers = [timer1, timer2, timer3]; + * const result = concat(...timers); + * + * result.subscribe(x => console.log(x)); + * + * // The spread is important. `concat(timers)` emits the Observables themselves. + * ``` + * * Concatenate the same Observable to repeat it * * ```ts