import { fromEvent, interval } from 'rxjs';
import { bufferWhen, delay } from 'rxjs/operators';
const click$ = fromEvent(document, 'click')
// random Emit close between 1-3s
const buffer$ = click$.pipe(bufferWhen(() => interval(1000 + Math.random() * 2000)));
Official Doc: rxjs.bufferWhen