dematerialize.js 1.7 KB

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