RxJS - Filtering Operator throttle

This operator will output as well as ignore values from the source observable for the time period determined by the input function taken as an argument and the same process will be repeated.


throttle(durationSelector: Observable or Promise): Observable


durationSelector − The argument durationSelector is an Observable or Promise that will ignore values from the values emitted from the source Observable.

Return value

It will return an observable that will throttle the values emitted from the source observable.


import { fromEvent, interval } from 'rxjs';

import { throttle} from 'rxjs/operators';

let btn = document.getElementById("btnclick");
let btn_clicks = fromEvent(btn, 'click');
let case1 = btn_clicks.pipe(throttle(ev => interval(2000)));
case1.subscribe(x => console.log(x));

When you click on the button the first click event will be emitted, the subsequent clicks will be delayed for the time given to throttle() operator.


throttle Operator
Kickstart Your Career

Get certified by completing the course

Get Started