mapTo.d.ts 1.1 KB

12345678910111213141516171819202122232425262728
  1. import { OperatorFunction } from '../interfaces';
  2. /**
  3. * Emits the given constant value on the output Observable every time the source
  4. * Observable emits a value.
  5. *
  6. * <span class="informal">Like {@link map}, but it maps every source value to
  7. * the same output value every time.</span>
  8. *
  9. * <img src="./img/mapTo.png" width="100%">
  10. *
  11. * Takes a constant `value` as argument, and emits that whenever the source
  12. * Observable emits a value. In other words, ignores the actual source value,
  13. * and simply uses the emission moment to know when to emit the given `value`.
  14. *
  15. * @example <caption>Map every click to the string 'Hi'</caption>
  16. * var clicks = Rx.Observable.fromEvent(document, 'click');
  17. * var greetings = clicks.mapTo('Hi');
  18. * greetings.subscribe(x => console.log(x));
  19. *
  20. * @see {@link map}
  21. *
  22. * @param {any} value The value to map each source value to.
  23. * @return {Observable} An Observable that emits the given `value` every time
  24. * the source Observable emits something.
  25. * @method mapTo
  26. * @owner Observable
  27. */
  28. export declare function mapTo<T, R>(value: R): OperatorFunction<T, R>;