61a7fb892973fa59406cc90a2a18bf36e46858ec684806641ceb2bc5a48896eb8e08a56b26b5eb9450cdc8631659aede2dde9197cc72c58a95863bf17b2f82 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { OperatorFunction, ObservableNotification, ValueFromNotification } from '../types';
  2. /**
  3. * Converts an Observable of {@link ObservableNotification} objects into the emissions
  4. * that they represent.
  5. *
  6. * <span class="informal">Unwraps {@link ObservableNotification} objects as actual `next`,
  7. * `error` and `complete` emissions. The opposite of {@link materialize}.</span>
  8. *
  9. * ![](dematerialize.png)
  10. *
  11. * `dematerialize` is assumed to operate an Observable that only emits
  12. * {@link ObservableNotification} 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
  20. *
  21. * Convert an Observable of Notifications to an actual Observable
  22. *
  23. * ```ts
  24. * import { NextNotification, ErrorNotification, of, dematerialize } from 'rxjs';
  25. *
  26. * const notifA: NextNotification<string> = { kind: 'N', value: 'A' };
  27. * const notifB: NextNotification<string> = { kind: 'N', value: 'B' };
  28. * const notifE: ErrorNotification = { kind: 'E', error: new TypeError('x.toUpperCase is not a function') };
  29. *
  30. * const materialized = of(notifA, notifB, notifE);
  31. *
  32. * const upperCase = materialized.pipe(dematerialize());
  33. * upperCase.subscribe({
  34. * next: x => console.log(x),
  35. * error: e => console.error(e)
  36. * });
  37. *
  38. * // Results in:
  39. * // A
  40. * // B
  41. * // TypeError: x.toUpperCase is not a function
  42. * ```
  43. *
  44. * @see {@link materialize}
  45. *
  46. * @return A function that returns an Observable that emits items and
  47. * notifications embedded in Notification objects emitted by the source
  48. * Observable.
  49. */
  50. export declare function dematerialize<N extends ObservableNotification<any>>(): OperatorFunction<N, ValueFromNotification<N>>;
  51. //# sourceMappingURL=dematerialize.d.ts.map