import { of, interval, from, timer } from 'rxjs';
import { map, mergeMap, switchMap } from 'rxjs/operators';
// map operator example
console.log('map ----------------------------');
const mapSource = of('Original String').pipe(
map(string => `Modified String!`)
);
mapSource.subscribe(x => console.log(x));
// switchMap operator example
console.log('switchMap ----------------------------');
const switched = of(1, 2, 3)
.pipe(
switchMap((x: number) => of(x, x * 2)
.pipe(
map(param => `Value ${param}`)
)
)
);
switched.subscribe(x => console.log(x));
// mergeMap operator
console.log('mergeMap ----------------------------');
const letters = of('a', 'b', 'c');
const result = letters.pipe(
mergeMap(x => from([1,2,3]).pipe(map(i => x+i))),
);
result.subscribe(x => console.log(x));
-
Notifications
You must be signed in to change notification settings - Fork 0
RXJS Operators
rodrigopaixao/rxjs-operators
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
RXJS Operators
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published