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

publishLast.d.ts 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { Observable } from '../Observable';
  2. import { ConnectableObservable } from '../observable/ConnectableObservable';
  3. import { UnaryFunction } from '../types';
  4. /**
  5. * Returns a connectable observable sequence that shares a single subscription to the
  6. * underlying sequence containing only the last notification.
  7. *
  8. * ![](publishLast.png)
  9. *
  10. * Similar to {@link publish}, but it waits until the source observable completes and stores
  11. * the last emitted value.
  12. * Similarly to {@link publishReplay} and {@link publishBehavior}, this keeps storing the last
  13. * value even if it has no more subscribers. If subsequent subscriptions happen, they will
  14. * immediately get that last stored value and complete.
  15. *
  16. * ## Example
  17. *
  18. * ```ts
  19. * import { interval } from 'rxjs';
  20. * import { publishLast, tap, take } from 'rxjs/operators';
  21. *
  22. * const connectable =
  23. * interval(1000)
  24. * .pipe(
  25. * tap(x => console.log("side effect", x)),
  26. * take(3),
  27. * publishLast());
  28. *
  29. * connectable.subscribe(
  30. * x => console.log( "Sub. A", x),
  31. * err => console.log("Sub. A Error", err),
  32. * () => console.log( "Sub. A Complete"));
  33. *
  34. * connectable.subscribe(
  35. * x => console.log( "Sub. B", x),
  36. * err => console.log("Sub. B Error", err),
  37. * () => console.log( "Sub. B Complete"));
  38. *
  39. * connectable.connect();
  40. *
  41. * // Results:
  42. * // "side effect 0"
  43. * // "side effect 1"
  44. * // "side effect 2"
  45. * // "Sub. A 2"
  46. * // "Sub. B 2"
  47. * // "Sub. A Complete"
  48. * // "Sub. B Complete"
  49. * ```
  50. *
  51. * @see {@link ConnectableObservable}
  52. * @see {@link publish}
  53. * @see {@link publishReplay}
  54. * @see {@link publishBehavior}
  55. *
  56. * @return {ConnectableObservable} An observable sequence that contains the elements of a
  57. * sequence produced by multicasting the source sequence.
  58. * @method publishLast
  59. * @owner Observable
  60. */
  61. export declare function publishLast<T>(): UnaryFunction<Observable<T>, ConnectableObservable<T>>;