Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

endWith.ts 4.1KB

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