- RxJS - Home
- RxJS - Overview
- RxJS - Environment Setup
- RxJS - Latest Updates
- RxJS - Observables
- RxJS - Operators
- RxJS - Working with Subscription
- RxJS - Working with Subjects
- RxJS - Working with Scheduler
- RxJS - Working with RxJS & Angular
- RxJS - Working with RxJS & ReactJS
- RxJS Useful Resources
- RxJS - Quick Guide
- RxJS - Useful Resources
- RxJS - Discussion
RxJS - Transformation Operator mapTo
A constant value is given as output along with the Observable every time the source Observable emits a value.
Syntax
mapTo(value: any): Observable
Parameters
value − It takes in the value as an argument and this value will be a map to the source value given.
Return value
It returns an Observable with values emitted when source observable emits.
Example
import { fromEvent } from 'rxjs';
import { mapTo } from 'rxjs/operators';
let btn = document.getElementById("btnclick");
let btn_clicks = fromEvent(btn, 'click');
let positions = btn_clicks.pipe(mapTo ("Testing MapTo"));
positions.subscribe(x => console.log(x));
Output
Advertisements