0b2efd0cdc2430a47c547180e1a310e994f797ccb2a2b681e1300535df6d591daa9c21658b7e6b881b9b25f0de25be0ca289a68867201e598a85f7b6c65459 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { Notification } from '../Notification';
  2. import { OperatorFunction, ObservableNotification } from '../types';
  3. /**
  4. * Represents all of the notifications from the source Observable as `next`
  5. * emissions marked with their original types within {@link Notification}
  6. * objects.
  7. *
  8. * <span class="informal">Wraps `next`, `error` and `complete` emissions in
  9. * {@link Notification} objects, emitted as `next` on the output Observable.
  10. * </span>
  11. *
  12. * ![](materialize.png)
  13. *
  14. * `materialize` returns an Observable that emits a `next` notification for each
  15. * `next`, `error`, or `complete` emission of the source Observable. When the
  16. * source Observable emits `complete`, the output Observable will emit `next` as
  17. * a Notification of type "complete", and then it will emit `complete` as well.
  18. * When the source Observable emits `error`, the output will emit `next` as a
  19. * Notification of type "error", and then `complete`.
  20. *
  21. * This operator is useful for producing metadata of the source Observable, to
  22. * be consumed as `next` emissions. Use it in conjunction with
  23. * {@link dematerialize}.
  24. *
  25. * ## Example
  26. *
  27. * Convert a faulty Observable to an Observable of Notifications
  28. *
  29. * ```ts
  30. * import { of, materialize, map } from 'rxjs';
  31. *
  32. * const letters = of('a', 'b', 13, 'd');
  33. * const upperCase = letters.pipe(map((x: any) => x.toUpperCase()));
  34. * const materialized = upperCase.pipe(materialize());
  35. *
  36. * materialized.subscribe(x => console.log(x));
  37. *
  38. * // Results in the following:
  39. * // - Notification { kind: 'N', value: 'A', error: undefined, hasValue: true }
  40. * // - Notification { kind: 'N', value: 'B', error: undefined, hasValue: true }
  41. * // - Notification { kind: 'E', value: undefined, error: TypeError { message: x.toUpperCase is not a function }, hasValue: false }
  42. * ```
  43. *
  44. * @see {@link Notification}
  45. * @see {@link dematerialize}
  46. *
  47. * @return A function that returns an Observable that emits
  48. * {@link Notification} objects that wrap the original emissions from the
  49. * source Observable with metadata.
  50. */
  51. export declare function materialize<T>(): OperatorFunction<T, Notification<T> & ObservableNotification<T>>;
  52. //# sourceMappingURL=materialize.d.ts.map