Beta (still building)

mergeScan

mergeScan operator allow you merge with other observable and add an accumulator

Example: mergeScan Operator simple use

import { interval, of } from 'rxjs';
import { mapTo, mergeScan } from 'rxjs/operators';
 
const source$ = interval(1000).pipe(mapTo(1));
const seed = 0;
const count$ = source$.pipe(
  mergeScan((acc, val) => of(acc + val), seed),
);

Example: mergeScan with click observable

import { fromEvent, of } from 'rxjs';
import { mapTo, mergeScan } from 'rxjs/operators';
 
const click$ = fromEvent(document, 'click').pipe(mapTo(1));
const seed = 0;
const count$ = click$.pipe(
  mergeScan((acc, val) => of(acc + val), seed),
);

Official Doc: rxjs.mergeScan