Demo: scan
scan is very similar to reduce, except that it emits the accumulated value at each step as it accumulates a new input.
scan( (acc,input) => accumulationFunction, seedValue);
const input = of(5, 15, 25, 40, 20)
.pipe(concatMap(v => of(v).pipe(delay(1000))));
//Emits the accumulated value on accumulation of each new value
const addUsingScan = scan(((acc,input) => acc+input), 500);
const output = input.pipe(addUsingScan).subscribe(v=>console.log(v))