Learn RxJS
Search…
pairwise

signature: pairwise(): Observable<Array>

Emit the previous and current values as an array.

Examples

Example 1:
1
// RxJS v6+
2
import { pairwise, take } from 'rxjs/operators';
3
import { interval } from 'rxjs';
4
5
//Returns: [0,1], [1,2], [2,3], [3,4], [4,5]
6
interval(1000)
7
.pipe(pairwise(), take(5))
8
.subscribe(console.log);
Copied!

Additional Resources

Last modified 1yr ago