[6a3a178] | 1 | import { Observable } from '../Observable';
|
---|
| 2 | import { concat } from '../observable/concat';
|
---|
| 3 | import { of } from '../observable/of';
|
---|
| 4 | import { MonoTypeOperatorFunction, SchedulerLike, OperatorFunction } from '../types';
|
---|
| 5 |
|
---|
| 6 | /* tslint:disable:max-line-length */
|
---|
| 7 | /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([source, [a, b, c]], scheduler).pipe(concatAll())`) */
|
---|
| 8 | export function endWith<T>(scheduler: SchedulerLike): MonoTypeOperatorFunction<T>;
|
---|
| 9 | /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([source, [a, b, c]], scheduler).pipe(concatAll())`) */
|
---|
| 10 | export function endWith<T, A>(v1: A, scheduler: SchedulerLike): OperatorFunction<T, T | A>;
|
---|
| 11 | /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([source, [a, b, c]], scheduler).pipe(concatAll())`) */
|
---|
| 12 | export function endWith<T, A, B>(v1: A, v2: B, scheduler: SchedulerLike): OperatorFunction<T, T | A | B>;
|
---|
| 13 | /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([source, [a, b, c]], scheduler).pipe(concatAll())`) */
|
---|
| 14 | export function endWith<T, A, B, C>(v1: A, v2: B, v3: C, scheduler: SchedulerLike): OperatorFunction<T, T | A | B | C>;
|
---|
| 15 | /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([source, [a, b, c]], scheduler).pipe(concatAll())`) */
|
---|
| 16 | export function endWith<T, A, B, C, D>(v1: A, v2: B, v3: C, v4: D, scheduler: SchedulerLike): OperatorFunction<T, T | A | B | C | D>;
|
---|
| 17 | /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([source, [a, b, c]], scheduler).pipe(concatAll())`) */
|
---|
| 18 | export function endWith<T, A, B, C, D, E>(v1: A, v2: B, v3: C, v4: D, v5: E, scheduler: SchedulerLike): OperatorFunction<T, T | A | B | C | D | E>;
|
---|
| 19 | /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([source, [a, b, c]], scheduler).pipe(concatAll())`) */
|
---|
| 20 | export function endWith<T, A, B, C, D, E, F>(v1: A, v2: B, v3: C, v4: D, v5: E, v6: F, scheduler: SchedulerLike): OperatorFunction<T, T | A | B | C | D | E | F>;
|
---|
| 21 |
|
---|
| 22 | export function endWith<T, A>(v1: A): OperatorFunction<T, T | A>;
|
---|
| 23 | export function endWith<T, A, B>(v1: A, v2: B): OperatorFunction<T, T | A | B>;
|
---|
| 24 | export function endWith<T, A, B, C>(v1: A, v2: B, v3: C): OperatorFunction<T, T | A | B | C>;
|
---|
| 25 | export function endWith<T, A, B, C, D>(v1: A, v2: B, v3: C, v4: D): OperatorFunction<T, T | A | B | C | D>;
|
---|
| 26 | export function endWith<T, A, B, C, D, E>(v1: A, v2: B, v3: C, v4: D, v5: E): OperatorFunction<T, T | A | B | C | D | E>;
|
---|
| 27 | export function endWith<T, A, B, C, D, E, F>(v1: A, v2: B, v3: C, v4: D, v5: E, v6: F): OperatorFunction<T, T | A | B | C | D | E | F>;
|
---|
| 28 | export function endWith<T, Z = T>(...array: Z[]): OperatorFunction<T, T | Z>;
|
---|
| 29 | /** @deprecated use {@link scheduled} and {@link concatAll} (e.g. `scheduled([source, [a, b, c]], scheduler).pipe(concatAll())`) */
|
---|
| 30 | export function endWith<T, Z = T>(...array: Array<Z | SchedulerLike>): OperatorFunction<T, T | Z>;
|
---|
| 31 | /* tslint:enable:max-line-length */
|
---|
| 32 |
|
---|
| 33 | /**
|
---|
| 34 | * Returns an Observable that emits the items you specify as arguments after it finishes emitting
|
---|
| 35 | * items emitted by the source Observable.
|
---|
| 36 | *
|
---|
| 37 | * ![](endWith.png)
|
---|
| 38 | *
|
---|
| 39 | * ## Example
|
---|
| 40 | * ### After the source observable completes, appends an emission and then completes too.
|
---|
| 41 | *
|
---|
| 42 | * ```ts
|
---|
| 43 | * import { of } from 'rxjs';
|
---|
| 44 | * import { endWith } from 'rxjs/operators';
|
---|
| 45 | *
|
---|
| 46 | * of('hi', 'how are you?', 'sorry, I have to go now').pipe(
|
---|
| 47 | * endWith('goodbye!'),
|
---|
| 48 | * )
|
---|
| 49 | * .subscribe(word => console.log(word));
|
---|
| 50 | * // result:
|
---|
| 51 | * // 'hi'
|
---|
| 52 | * // 'how are you?'
|
---|
| 53 | * // 'sorry, I have to go now'
|
---|
| 54 | * // 'goodbye!'
|
---|
| 55 | * ```
|
---|
| 56 | *
|
---|
| 57 | * @param {...T} values - Items you want the modified Observable to emit last.
|
---|
| 58 | * @param {SchedulerLike} [scheduler] - A {@link SchedulerLike} to use for scheduling
|
---|
| 59 | * the emissions of the `next` notifications.
|
---|
| 60 | * @return {Observable} An Observable that emits the items emitted by the source Observable
|
---|
| 61 | * and then emits the items in the specified Iterable.
|
---|
| 62 | * @method endWith
|
---|
| 63 | * @owner Observable
|
---|
| 64 | */
|
---|
| 65 | export function endWith<T>(...array: Array<T | SchedulerLike>): MonoTypeOperatorFunction<T> {
|
---|
| 66 | return (source: Observable<T>) => concat(source, of(...array)) as Observable<T>;
|
---|
| 67 | }
|
---|