auditTime
signature: auditTime(duration: number, scheduler?: Scheduler): Observable
auditTime(duration: number, scheduler?: Scheduler): Observable
Ignore for given time then emit most recent value
Why use auditTime
auditTime
When you are interested in ignoring a source observable for a given amout of time, you can use auditTime
. A possible use case is to only emit certain events (i.e. mouse clicks) at a maximum rate per second. After the specified duration has passed, the timer is disabled and the most recent source value is emitted on the output Observable, and this process repeats for the next source value.
:bulb: If you want the timer to reset whenever a new event occurs on the source observable, you can use debounceTime
Examples
Example 1: Emit clicks at a rate of at most one click per second
( stackBlitz )
Additional Resources
:newspaper: - Official docs
:file_folder: Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/auditTime.ts
Last updated