
- RxJS Tutorial
- RxJS - Home
- RxJS - Overview
- RxJS - Environment Setup
- RxJS - Latest Updates
- RxJS - Observables
- RxJS - Operators
- RxJS - Working with Subscription
- RxJS - Working with Subjects
- RxJS - Working with Scheduler
- RxJS - Working with RxJS & Angular
- RxJS - Working with RxJS & ReactJS
- RxJS Useful Resources
- RxJS - Quick Guide
- RxJS - Useful Resources
- RxJS - Discussion
RxJS - Utility Operator delay
This operator delays the values emitted from the source Observable based on the timeout given.
Syntax
delay(timeout: number): Observable
Parameters
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.
Example
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
Output

Advertisements