dematerialize.d.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { Notification } from '../Notification';
  2. import { OperatorFunction } from '../interfaces';
  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. export declare function dematerialize<T>(): OperatorFunction<Notification<T>, T>;