pairwise() will remember the last emit value.
const src = interval(1000) .pipe( pairwise(), scan((acc, [prev, curr]) => { console.log(prev, curr) return acc + curr; }, 0) ).subscribe() // 0 1
[RxJS] Remember previous value by using pairwise operator
原文:https://www.cnblogs.com/Answer1215/p/12660363.html