Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save armanozak/fb08eae62ddf7e06cea1151b55319c0d to your computer and use it in GitHub Desktop.
Save armanozak/fb08eae62ddf7e06cea1151b55319c0d to your computer and use it in GitHub Desktop.
[What's New in RxJS 7] RxJS 7 firstValueFrom and lastValueFrom #blog #rxjs
import { interval, firstValueFrom, lastValueFrom } from "rxjs";
import { map, take } from "rxjs/operators";
const count1To5$ = interval(1000).pipe(
take(5),
map(i => i + 1)
);
firstValueFrom(count1To5$).then(console.log);
// (after ~1s) 1
lastValueFrom(count1To5$).then(console.log);
// (after ~5s) 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment