Skip to content

Instantly share code, notes, and snippets.

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