RxJS - Utility Operator delay

This operator delays the values emitted from the source Observable based on the timeout given.


delay(timeout: number): Observable


timeout − It will be in milliseconds or a Date which will delay the emission of the values from the source observable.

Return value

An observable will be returned that will use the timeout or date given to delay the source observable.


import { fromEvent } from 'rxjs';
import { delay } from 'rxjs/operators';

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

Here the click event is delayed using debounce() operator


delay Operator
Kickstart Your Career

Get certified by completing the course

Get Started