dematerialize.js 1.8KB

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