Skip to content

Instantly share code, notes, and snippets.

@armanozak
Created May 3, 2021 09:04
Show Gist options
  • Save armanozak/5a4c9bc375bf9344b7264b38b0a9bff3 to your computer and use it in GitHub Desktop.
Save armanozak/5a4c9bc375bf9344b7264b38b0a9bff3 to your computer and use it in GitHub Desktop.
[What's New in RxJS 7] RxJS 7 combineLatestWith #blog #rxjs
import { interval } from "rxjs";
import { combineLatestWith, map } 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(combineLatestWith(count6To9$)).subscribe(console.log);
// (after ~1s) [1,6]
// (after ~1s) [2,6] (immediately) [2,7]
// (after ~1s) [3,7] (immediately) [3,8]
// (after ~1s) [4,8] (immediately) [4,9]
// (after ~1s) [5,9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment