Front end of the Slack clone application.

dematerialize.js 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /** PURE_IMPORTS_START .._Subscriber PURE_IMPORTS_END */
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b)
  4. if (b.hasOwnProperty(p))
  5. d[p] = b[p];
  6. function __() { this.constructor = d; }
  7. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8. };
  9. import { Subscriber } from '../Subscriber';
  10. /**
  11. * Converts an Observable of {@link Notification} objects into the emissions
  12. * that they represent.
  13. *
  14. * <span class="informal">Unwraps {@link Notification} objects as actual `next`,
  15. * `error` and `complete` emissions. The opposite of {@link materialize}.</span>
  16. *
  17. * <img src="./img/dematerialize.png" width="100%">
  18. *
  19. * `dematerialize` is assumed to operate an Observable that only emits
  20. * {@link Notification} objects as `next` emissions, and does not emit any
  21. * `error`. Such Observable is the output of a `materialize` operation. Those
  22. * notifications are then unwrapped using the metadata they contain, and emitted
  23. * as `next`, `error`, and `complete` on the output Observable.
  24. *
  25. * Use this operator in conjunction with {@link materialize}.
  26. *
  27. * @example <caption>Convert an Observable of Notifications to an actual Observable</caption>
  28. * var notifA = new Rx.Notification('N', 'A');
  29. * var notifB = new Rx.Notification('N', 'B');
  30. * var notifE = new Rx.Notification('E', void 0,
  31. * new TypeError('x.toUpperCase is not a function')
  32. * );
  33. * var materialized = Rx.Observable.of(notifA, notifB, notifE);
  34. * var upperCase = materialized.dematerialize();
  35. * upperCase.subscribe(x => console.log(x), e => console.error(e));
  36. *
  37. * // Results in:
  38. * // A
  39. * // B
  40. * // TypeError: x.toUpperCase is not a function
  41. *
  42. * @see {@link Notification}
  43. * @see {@link materialize}
  44. *
  45. * @return {Observable} An Observable that emits items and notifications
  46. * embedded in Notification objects emitted by the source Observable.
  47. * @method dematerialize
  48. * @owner Observable
  49. */
  50. export function dematerialize() {
  51. return function dematerializeOperatorFunction(source) {
  52. return source.lift(new DeMaterializeOperator());
  53. };
  54. }
  55. var DeMaterializeOperator = /*@__PURE__*/ (/*@__PURE__*/ function () {
  56. function DeMaterializeOperator() {
  57. }
  58. DeMaterializeOperator.prototype.call = function (subscriber, source) {
  59. return source.subscribe(new DeMaterializeSubscriber(subscriber));
  60. };
  61. return DeMaterializeOperator;
  62. }());
  63. /**
  64. * We need this JSDoc comment for affecting ESDoc.
  65. * @ignore
  66. * @extends {Ignored}
  67. */
  68. var DeMaterializeSubscriber = /*@__PURE__*/ (/*@__PURE__*/ function (_super) {
  69. __extends(DeMaterializeSubscriber, _super);
  70. function DeMaterializeSubscriber(destination) {
  71. _super.call(this, destination);
  72. }
  73. DeMaterializeSubscriber.prototype._next = function (value) {
  74. value.observe(this.destination);
  75. };
  76. return DeMaterializeSubscriber;
  77. }(Subscriber));
  78. //# sourceMappingURL=dematerialize.js.map