123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. var materialize_1 = require('../operators/materialize');
  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. * <img src="./img/materialize.png" width="100%">
  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 <caption>Convert a faulty Observable to an Observable of Notifications</caption>
  26. * var letters = Rx.Observable.of('a', 'b', 13, 'd');
  27. * var upperCase = letters.map(x => x.toUpperCase());
  28. * var materialized = upperCase.materialize();
  29. * materialized.subscribe(x => console.log(x));
  30. *
  31. * // Results in the following:
  32. * // - Notification {kind: "N", value: "A", error: undefined, hasValue: true}
  33. * // - Notification {kind: "N", value: "B", error: undefined, hasValue: true}
  34. * // - Notification {kind: "E", value: undefined, error: TypeError:
  35. * // x.toUpperCase is not a function at MapSubscriber.letters.map.x
  36. * // [as project] (http://1…, hasValue: false}
  37. *
  38. * @see {@link Notification}
  39. * @see {@link dematerialize}
  40. *
  41. * @return {Observable<Notification<T>>} An Observable that emits
  42. * {@link Notification} objects that wrap the original emissions from the source
  43. * Observable with metadata.
  44. * @method materialize
  45. * @owner Observable
  46. */
  47. function materialize() {
  48. return materialize_1.materialize()(this);
  49. }
  50. exports.materialize = materialize;
  51. //# sourceMappingURL=materialize.js.map