- 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 map
In the case of map operator, a project function is applied on each value on the source Observable and the same output is emitted as an Observable.
Syntax
map(project_func: function): Observable
Parameters
project_func − It takes in project_func as the argument which is applied to all the values of source observable.
Return value
An observable, with values as per the result of the project_func.
Example
import { fromEvent } from 'rxjs';
import { map } from 'rxjs/operators';
let btn = document.getElementById("btnclick");
let btn_clicks = fromEvent(btn, 'click');
let positions = btn_clicks.pipe(map(ev => ev));
positions.subscribe(x => console.log("x:"+x.clientX +" and y: "+x.clientY));
Output
Advertisements