I have an Observable:
1----2----3----3----2----1-|
I use
.bufferCount(2, 1)
and the output is
--[1,2]-[2,3]-[3,3]-[3,2]-[2,1]-|
then I chain
.filter(twoEmissions => twoEmissions[0] !== twoEmissions[1])
which makes:
--[1,2]-[2,3]-------[3,2]-[2,1]-|
then I chain
.map(twoEmissions => twoEmissions[1])
to leave only latest emissions, so my final output is:
-----2-----3------------2----1---|
My problem is that first emission is ommited int this case. I tried to use buffer() insted of bufferCount() with following closingNotifier:
bufferClosingNotifier = sourceObservable$
.scan((acc, val, index) => (index), 0)
.filter((index: number) => index === 0 || index > 0 && index % 2 !== 0)
It emits 1st, 3rd, 5th, 7th... emission but they are not overlapping.
How can I have bufferCount(2, 1) but emitting first emission of source observable anyway?
.startWith(undefined).bufferCount(2, 1)- cartant