1 import { Observable } from '../Observable';
2 import { concat } from '../observable/concat';
3 import { isScheduler } from '../util/isScheduler';
4 import { MonoTypeOperatorFunction, OperatorFunction, SchedulerLike } from '../types';
6 /* tslint:disable:max-line-length */
7 /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([[a, b, c], source], scheduler).pipe(concatAll())`) */
8 export function startWith<T>(scheduler: SchedulerLike): MonoTypeOperatorFunction<T>;
9 /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([[a, b, c], source], scheduler).pipe(concatAll())`) */
10 export function startWith<T, D>(v1: D, scheduler: SchedulerLike): OperatorFunction<T, T | D>;
11 /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([[a, b, c], source], scheduler).pipe(concatAll())`) */
12 export function startWith<T, D, E>(v1: D, v2: E, scheduler: SchedulerLike): OperatorFunction<T, T | D | E>;
13 /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([[a, b, c], source], scheduler).pipe(concatAll())`) */
14 export function startWith<T, D, E, F>(v1: D, v2: E, v3: F, scheduler: SchedulerLike): OperatorFunction<T, T | D | E | F>;
15 /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([[a, b, c], source], scheduler).pipe(concatAll())`) */
16 export function startWith<T, D, E, F, G>(v1: D, v2: E, v3: F, v4: G, scheduler: SchedulerLike): OperatorFunction<T, T | D | E | F | G>;
17 /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([[a, b, c], source], scheduler).pipe(concatAll())`) */
18 export function startWith<T, D, E, F, G, H>(v1: D, v2: E, v3: F, v4: G, v5: H, scheduler: SchedulerLike): OperatorFunction<T, T | D | E | F | G | H>;
19 /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([[a, b, c], source], scheduler).pipe(concatAll())`) */
20 export function startWith<T, D, E, F, G, H, I>(v1: D, v2: E, v3: F, v4: G, v5: H, v6: I, scheduler: SchedulerLike): OperatorFunction<T, T | D | E | F | G | H | I>;
22 export function startWith<T, D>(v1: D): OperatorFunction<T, T | D>;
23 export function startWith<T, D, E>(v1: D, v2: E): OperatorFunction<T, T | D | E>;
24 export function startWith<T, D, E, F>(v1: D, v2: E, v3: F): OperatorFunction<T, T | D | E | F>;
25 export function startWith<T, D, E, F, G>(v1: D, v2: E, v3: F, v4: G): OperatorFunction<T, T | D | E | F | G>;
26 export function startWith<T, D, E, F, G, H>(v1: D, v2: E, v3: F, v4: G, v5: H): OperatorFunction<T, T | D | E | F | G | H>;
27 export function startWith<T, D, E, F, G, H, I>(v1: D, v2: E, v3: F, v4: G, v5: H, v6: I): OperatorFunction<T, T | D | E | F | G | H | I>;
28 export function startWith<T, D = T>(...array: D[]): OperatorFunction<T, T | D>;
29 /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([[a, b, c], source], scheduler).pipe(concatAll())`) */
30 export function startWith<T, D = T>(...array: Array<D | SchedulerLike>): OperatorFunction<T, T | D>;
31 /* tslint:enable:max-line-length */
34 * Returns an Observable that emits the items you specify as arguments before it begins to emit
35 * items emitted by the source Observable.
37 * <span class="informal">First emits its arguments in order, and then any
38 * emissions from the source.</span>
44 * Start the chain of emissions with `"first"`, `"second"`
47 * import { of } from 'rxjs';
48 * import { startWith } from 'rxjs/operators';
51 * .pipe(startWith("first", "second"))
52 * .subscribe(x => console.log(x));
60 * @param {...T} values - Items you want the modified Observable to emit first.
61 * @param {SchedulerLike} [scheduler] - A {@link SchedulerLike} to use for scheduling
62 * the emissions of the `next` notifications.
63 * @return {Observable} An Observable that emits the items in the specified Iterable and then emits the items
64 * emitted by the source Observable.
68 export function startWith<T, D>(...array: Array<T | SchedulerLike>): OperatorFunction<T, T | D> {
69 const scheduler = array[array.length - 1] as SchedulerLike;
70 if (isScheduler(scheduler)) {
73 return (source: Observable<T>) => concat(array as T[], source, scheduler);
75 return (source: Observable<T>) => concat(array as T[], source);