mapTo.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var operators_1 = require("rxjs/operators");
  4. /**
  5. * Emits the given constant value on the output Observable every time the source
  6. * Observable emits a value.
  7. *
  8. * <span class="informal">Like {@link map}, but it maps every source value to
  9. * the same output value every time.</span>
  10. *
  11. * <img src="./img/mapTo.png" width="100%">
  12. *
  13. * Takes a constant `value` as argument, and emits that whenever the source
  14. * Observable emits a value. In other words, ignores the actual source value,
  15. * and simply uses the emission moment to know when to emit the given `value`.
  16. *
  17. * @example <caption>Map every click to the string 'Hi'</caption>
  18. * var clicks = Rx.Observable.fromEvent(document, 'click');
  19. * var greetings = clicks.mapTo('Hi');
  20. * greetings.subscribe(x => console.log(x));
  21. *
  22. * @see {@link map}
  23. *
  24. * @param {any} value The value to map each source value to.
  25. * @return {Observable} An Observable that emits the given `value` every time
  26. * the source Observable emits something.
  27. * @method mapTo
  28. * @owner Observable
  29. */
  30. function mapTo(value) {
  31. return operators_1.mapTo(value)(this);
  32. }
  33. exports.mapTo = mapTo;
  34. //# sourceMappingURL=mapTo.js.map