Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

publishLast.d.ts 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. * ```js
  19. * const connectable =
  20. * interval(1000)
  21. * .pipe(
  22. * tap(x => console.log("side effect", x)),
  23. * take(3),
  24. * publishLast());
  25. *
  26. * connectable.subscribe(
  27. * x => console.log( "Sub. A", x),
  28. * err => console.log("Sub. A Error", err),
  29. * () => console.log( "Sub. A Complete"));
  30. *
  31. * connectable.subscribe(
  32. * x => console.log( "Sub. B", x),
  33. * err => console.log("Sub. B Error", err),
  34. * () => console.log( "Sub. B Complete"));
  35. *
  36. * connectable.connect();
  37. *
  38. * // Results:
  39. * // "side effect 0"
  40. * // "side effect 1"
  41. * // "side effect 2"
  42. * // "Sub. A 2"
  43. * // "Sub. B 2"
  44. * // "Sub. A Complete"
  45. * // "Sub. B Complete"
  46. * ```
  47. *
  48. * @see {@link ConnectableObservable}
  49. * @see {@link publish}
  50. * @see {@link publishReplay}
  51. * @see {@link publishBehavior}
  52. *
  53. * @return {ConnectableObservable} An observable sequence that contains the elements of a
  54. * sequence produced by multicasting the source sequence.
  55. * @method publishLast
  56. * @owner Observable
  57. */
  58. export declare function publishLast<T>(): UnaryFunction<Observable<T>, ConnectableObservable<T>>;