Get difference between last two values of an RxJS Observable
Use pairwise:
scroll
.pairwise()
.map(([a, b]) => b - a);
Old question, but to add info for RxJS version 5, where the API surface has changed somewhat and it took me some time to find the answer: the equivalent to pairwise
would be bufferWithCount(2,1)
(v4) or bufferCount(2,1)
(v5).