This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
of(1, 2, 3).pipe(exhaustMap((x) => interval(2000) | |
.pipe(take(3),tap((t) => console.log(x, t)))) ) | |
.subscribe((d) => console.log('GOT ', d)); | |
// Merge Map : 1 0, 2 0, 3 0, 1 1, 2 1, 3 1, 1 2, 2 2, 3 2 | |
// switchMap: 3 0, 3 1, 3 2 | |
// ConcatMap: 1 0, 1 1, 1 2, 2 0, 2 1, 2 2, 3 0, 3 1, 3 2, | |
// exhaustMap: 1 0, 1 1, 1 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fork join - subscribe to several parallel observables, wait for all to complete and do something with the result | |
// https://medium.com/better-programming/rxjs-forkjoin-never-use-array-indexes-in-subscribe-1f4005582ae8 | |
forkJoin( | |
this.http.get('some/api/welcomeMessage'), | |
language$, | |
dateRange$ | |
// Use tab to handle data processing for each observable separately | |
.pipe(tap(([startDate, endDate]) => { | |
this.startDate = startDate; | |
this.endDate = endDate; |