UI for Zipcoin Blue

dematerialize.js 2.8KB

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