Created
May 3, 2021 09:05
-
-
Save armanozak/9ade52f3da7ff6c304d2a7e8b8850afa to your computer and use it in GitHub Desktop.
[What's New in RxJS 7] RxJS 7 mergeWith #blog #rxjs
This file contains hidden or 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
import { interval } from "rxjs"; | |
import { map, mergeWith } from "rxjs/operators"; | |
const count1To5$ = interval(1000).pipe( | |
take(5), | |
map(i => i + 1) | |
); | |
const count6To9$ = interval(1000).pipe( | |
take(4), | |
map(i => i + 6) | |
); | |
count1To5$.pipe(mergeWith(count6To9$)).subscribe(console.log); | |
// (after ~1s) 1 (immediately) 6 | |
// (after ~1s) 2 (immediately) 7 | |
// (after ~1s) 3 (immediately) 8 | |
// (after ~1s) 4 (immediately) 9 | |
// (after ~1s) 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment