source: trip-planner-front/node_modules/rxjs/src/internal/observable/concat.ts@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 9.4 KB
Line 
1import { Observable } from '../Observable';
2import { ObservableInput, SchedulerLike, ObservedValueOf } from '../types';
3import { isScheduler } from '../util/isScheduler';
4import { of } from './of';
5import { from } from './from';
6import { concatAll } from '../operators/concatAll';
7
8/* tslint:disable:max-line-length */
9/** @deprecated Use {@link scheduled} and {@link concatAll} (e.g. `scheduled([o1, o2, o3], scheduler).pipe(concatAll())`) */
10export function concat<O1 extends ObservableInput<any>>(v1: O1, scheduler: SchedulerLike): Observable<ObservedValueOf<O1>>;
11/** @deprecated Use {@link scheduled} and {@link concatAll} (e.g. `scheduled([o1, o2, o3], scheduler).pipe(concatAll())`) */
12export function concat<O1 extends ObservableInput<any>, O2 extends ObservableInput<any>>(v1: O1, v2: O2, scheduler: SchedulerLike): Observable<ObservedValueOf<O1> | ObservedValueOf<O2>>;
13/** @deprecated Use {@link scheduled} and {@link concatAll} (e.g. `scheduled([o1, o2, o3], scheduler).pipe(concatAll())`) */
14export function concat<O1 extends ObservableInput<any>, O2 extends ObservableInput<any>, O3 extends ObservableInput<any>>(v1: O1, v2: O2, v3: O3, scheduler: SchedulerLike): Observable<ObservedValueOf<O1> | ObservedValueOf<O2> | ObservedValueOf<O3>>;
15/** @deprecated Use {@link scheduled} and {@link concatAll} (e.g. `scheduled([o1, o2, o3], scheduler).pipe(concatAll())`) */
16export function concat<O1 extends ObservableInput<any>, O2 extends ObservableInput<any>, O3 extends ObservableInput<any>, O4 extends ObservableInput<any>>(v1: O1, v2: O2, v3: O3, v4: O4, scheduler: SchedulerLike): Observable<ObservedValueOf<O1> | ObservedValueOf<O2> | ObservedValueOf<O3> | ObservedValueOf<O4>>;
17/** @deprecated Use {@link scheduled} and {@link concatAll} (e.g. `scheduled([o1, o2, o3], scheduler).pipe(concatAll())`) */
18export function concat<O1 extends ObservableInput<any>, O2 extends ObservableInput<any>, O3 extends ObservableInput<any>, O4 extends ObservableInput<any>, O5 extends ObservableInput<any>>(v1: O1, v2: O2, v3: O3, v4: O4, v5: O5, scheduler: SchedulerLike): Observable<ObservedValueOf<O1> | ObservedValueOf<O2> | ObservedValueOf<O3> | ObservedValueOf<O4> | ObservedValueOf<O5>>;
19/** @deprecated Use {@link scheduled} and {@link concatAll} (e.g. `scheduled([o1, o2, o3], scheduler).pipe(concatAll())`) */
20export function concat<O1 extends ObservableInput<any>, O2 extends ObservableInput<any>, O3 extends ObservableInput<any>, O4 extends ObservableInput<any>, O5 extends ObservableInput<any>, O6 extends ObservableInput<any>>(v1: O1, v2: O2, v3: O3, v4: O4, v5: O5, v6: O6, scheduler: SchedulerLike): Observable<ObservedValueOf<O1> | ObservedValueOf<O2> | ObservedValueOf<O3> | ObservedValueOf<O4> | ObservedValueOf<O5> | ObservedValueOf<O6>>;
21
22export function concat<O1 extends ObservableInput<any>>(v1: O1): Observable<ObservedValueOf<O1>>;
23export function concat<O1 extends ObservableInput<any>, O2 extends ObservableInput<any>>(v1: O1, v2: O2): Observable<ObservedValueOf<O1> | ObservedValueOf<O2>>;
24export function concat<O1 extends ObservableInput<any>, O2 extends ObservableInput<any>, O3 extends ObservableInput<any>>(v1: O1, v2: O2, v3: O3): Observable<ObservedValueOf<O1> | ObservedValueOf<O2> | ObservedValueOf<O3>>;
25export function concat<O1 extends ObservableInput<any>, O2 extends ObservableInput<any>, O3 extends ObservableInput<any>, O4 extends ObservableInput<any>>(v1: O1, v2: O2, v3: O3, v4: O4): Observable<ObservedValueOf<O1> | ObservedValueOf<O2> | ObservedValueOf<O3> | ObservedValueOf<O4>>;
26export function concat<O1 extends ObservableInput<any>, O2 extends ObservableInput<any>, O3 extends ObservableInput<any>, O4 extends ObservableInput<any>, O5 extends ObservableInput<any>>(v1: O1, v2: O2, v3: O3, v4: O4, v5: O5): Observable<ObservedValueOf<O1> | ObservedValueOf<O2> | ObservedValueOf<O3> | ObservedValueOf<O4> | ObservedValueOf<O5>>;
27export function concat<O1 extends ObservableInput<any>, O2 extends ObservableInput<any>, O3 extends ObservableInput<any>, O4 extends ObservableInput<any>, O5 extends ObservableInput<any>, O6 extends ObservableInput<any>>(v1: O1, v2: O2, v3: O3, v4: O4, v5: O5, v6: O6): Observable<ObservedValueOf<O1> | ObservedValueOf<O2> | ObservedValueOf<O3> | ObservedValueOf<O4> | ObservedValueOf<O5> | ObservedValueOf<O6>>;
28export function concat<O extends ObservableInput<any>>(...observables: O[]): Observable<ObservedValueOf<O>>;
29/** @deprecated Use {@link scheduled} and {@link concatAll} (e.g. `scheduled([o1, o2, o3], scheduler).pipe(concatAll())`) */
30export function concat<O extends ObservableInput<any>>(...observables: (O | SchedulerLike)[]): Observable<ObservedValueOf<O>>;
31export function concat<R>(...observables: ObservableInput<any>[]): Observable<R>;
32/** @deprecated Use {@link scheduled} and {@link concatAll} (e.g. `scheduled([o1, o2, o3], scheduler).pipe(concatAll())`) */
33export function concat<R>(...observables: (ObservableInput<any> | SchedulerLike)[]): Observable<R>;
34/* tslint:enable:max-line-length */
35/**
36 * Creates an output Observable which sequentially emits all values from given
37 * Observable and then moves on to the next.
38 *
39 * <span class="informal">Concatenates multiple Observables together by
40 * sequentially emitting their values, one Observable after the other.</span>
41 *
42 * ![](concat.png)
43 *
44 * `concat` joins multiple Observables together, by subscribing to them one at a time and
45 * merging their results into the output Observable. You can pass either an array of
46 * Observables, or put them directly as arguments. Passing an empty array will result
47 * in Observable that completes immediately.
48 *
49 * `concat` will subscribe to first input Observable and emit all its values, without
50 * changing or affecting them in any way. When that Observable completes, it will
51 * subscribe to then next Observable passed and, again, emit its values. This will be
52 * repeated, until the operator runs out of Observables. When last input Observable completes,
53 * `concat` will complete as well. At any given moment only one Observable passed to operator
54 * emits values. If you would like to emit values from passed Observables concurrently, check out
55 * {@link merge} instead, especially with optional `concurrent` parameter. As a matter of fact,
56 * `concat` is an equivalent of `merge` operator with `concurrent` parameter set to `1`.
57 *
58 * Note that if some input Observable never completes, `concat` will also never complete
59 * and Observables following the one that did not complete will never be subscribed. On the other
60 * hand, if some Observable simply completes immediately after it is subscribed, it will be
61 * invisible for `concat`, which will just move on to the next Observable.
62 *
63 * If any Observable in chain errors, instead of passing control to the next Observable,
64 * `concat` will error immediately as well. Observables that would be subscribed after
65 * the one that emitted error, never will.
66 *
67 * If you pass to `concat` the same Observable many times, its stream of values
68 * will be "replayed" on every subscription, which means you can repeat given Observable
69 * as many times as you like. If passing the same Observable to `concat` 1000 times becomes tedious,
70 * you can always use {@link repeat}.
71 *
72 * ## Examples
73 * ### Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10
74 * ```ts
75 * import { concat, interval, range } from 'rxjs';
76 * import { take } from 'rxjs/operators';
77 *
78 * const timer = interval(1000).pipe(take(4));
79 * const sequence = range(1, 10);
80 * const result = concat(timer, sequence);
81 * result.subscribe(x => console.log(x));
82 *
83 * // results in:
84 * // 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10
85 * ```
86 *
87 * ### Concatenate 3 Observables
88 * ```ts
89 * import { concat, interval } from 'rxjs';
90 * import { take } from 'rxjs/operators';
91 *
92 * const timer1 = interval(1000).pipe(take(10));
93 * const timer2 = interval(2000).pipe(take(6));
94 * const timer3 = interval(500).pipe(take(10));
95 *
96 * const result = concat(timer1, timer2, timer3);
97 * result.subscribe(x => console.log(x));
98 *
99 * // results in the following:
100 * // (Prints to console sequentially)
101 * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9
102 * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5
103 * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9
104 * ```
105 *
106 * ### Concatenate the same Observable to repeat it
107 * ```ts
108 * import { concat, interval } from 'rxjs';
109 * import { take } from 'rxjs/operators';
110 *
111 * const timer = interval(1000).pipe(take(2));
112 *
113 * concat(timer, timer) // concatenating the same Observable!
114 * .subscribe(
115 * value => console.log(value),
116 * err => {},
117 * () => console.log('...and it is done!')
118 * );
119 *
120 * // Logs:
121 * // 0 after 1s
122 * // 1 after 2s
123 * // 0 after 3s
124 * // 1 after 4s
125 * // "...and it is done!" also after 4s
126 * ```
127 *
128 * @see {@link concatAll}
129 * @see {@link concatMap}
130 * @see {@link concatMapTo}
131 * @see {@link startWith}
132 * @see {@link endWith}
133 *
134 * @param {ObservableInput} input1 An input Observable to concatenate with others.
135 * @param {ObservableInput} input2 An input Observable to concatenate with others.
136 * More than one input Observables may be given as argument.
137 * @param {SchedulerLike} [scheduler=null] An optional {@link SchedulerLike} to schedule each
138 * Observable subscription on.
139 * @return {Observable} All values of each passed Observable merged into a
140 * single Observable, in order, in serial fashion.
141 * @static true
142 * @name concat
143 * @owner Observable
144 */
145export function concat<O extends ObservableInput<any>, R>(...observables: Array<O | SchedulerLike>): Observable<ObservedValueOf<O> | R> {
146 return concatAll<R>()(of(...observables));
147}
Note: See TracBrowser for help on using the repository browser.