I have been trying to get the old and new value in every emission. I have seen the option of using pairwise
or bufferCount
but they don't allow to keep the first value.
The goal would to go from:
---1---2---3---4---5---
To:
---null,1---1,2---2,3---3,4---4,5---
Any ideas?
You can use startWith(null)
to initialize the operator (whichever you use) and then it'll emit on every value:
// or bufferCount(2, 1)
source.startWith(null).pairwise().subscribe(...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With