On this page
mapTo
function deprecated operator
Emits the given constant value on the output Observable every time the source Observable emits a value.
Deprecation Notes
To be removed in v9. Use map instead: map(() => value).
mapTo<R>(value: R): OperatorFunction<unknown, R>
   Parameters
| value | R | The value to map each source value to. | 
Returns
OperatorFunction<unknown, R>: A function that returns an Observable that emits the given value every time the source Observable emits.
Description
Like map, but it maps every source value to the same output value every time.
Takes a constant value as argument, and emits that whenever the source Observable emits a value. In other words, ignores the actual source value, and simply uses the emission moment to know when to emit the given value.
Example
Map every click to the string 'Hi'
import { fromEvent, mapTo } from 'rxjs';
const clicks = fromEvent(document, 'click');
const greetings = clicks.pipe(mapTo('Hi'));
greetings.subscribe(x => console.log(x));See Also
© 2015–2022 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
 https://rxjs.dev/api/operators/mapTo