dematerialize.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var operators_1 = require("rxjs/operators");
  4. /**
  5. * Converts an Observable of {@link Notification} objects into the emissions
  6. * that they represent.
  7. *
  8. * <span class="informal">Unwraps {@link Notification} objects as actual `next`,
  9. * `error` and `complete` emissions. The opposite of {@link materialize}.</span>
  10. *
  11. * <img src="./img/dematerialize.png" width="100%">
  12. *
  13. * `dematerialize` is assumed to operate an Observable that only emits
  14. * {@link Notification} objects as `next` emissions, and does not emit any
  15. * `error`. Such Observable is the output of a `materialize` operation. Those
  16. * notifications are then unwrapped using the metadata they contain, and emitted
  17. * as `next`, `error`, and `complete` on the output Observable.
  18. *
  19. * Use this operator in conjunction with {@link materialize}.
  20. *
  21. * @example <caption>Convert an Observable of Notifications to an actual Observable</caption>
  22. * var notifA = new Rx.Notification('N', 'A');
  23. * var notifB = new Rx.Notification('N', 'B');
  24. * var notifE = new Rx.Notification('E', void 0,
  25. * new TypeError('x.toUpperCase is not a function')
  26. * );
  27. * var materialized = Rx.Observable.of(notifA, notifB, notifE);
  28. * var upperCase = materialized.dematerialize();
  29. * upperCase.subscribe(x => console.log(x), e => console.error(e));
  30. *
  31. * // Results in:
  32. * // A
  33. * // B
  34. * // TypeError: x.toUpperCase is not a function
  35. *
  36. * @see {@link Notification}
  37. * @see {@link materialize}
  38. *
  39. * @return {Observable} An Observable that emits items and notifications
  40. * embedded in Notification objects emitted by the source Observable.
  41. * @method dematerialize
  42. * @owner Observable
  43. */
  44. function dematerialize() {
  45. return operators_1.dematerialize()(this);
  46. }
  47. exports.dematerialize = dematerialize;
  48. //# sourceMappingURL=dematerialize.js.map