UNPKG

2.26 kBTypeScriptView Raw
1import { MonoTypeOperatorFunction, SchedulerLike } from '../types';
2/**
3 * Ignores source values for `duration` milliseconds, then emits the most recent
4 * value from the source Observable, then repeats this process.
5 *
6 * <span class="informal">When it sees a source value, it ignores that plus
7 * the next ones for `duration` milliseconds, and then it emits the most recent
8 * value from the source.</span>
9 *
10 * ![](auditTime.png)
11 *
12 * `auditTime` is similar to `throttleTime`, but emits the last value from the
13 * silenced time window, instead of the first value. `auditTime` emits the most
14 * recent value from the source Observable on the output Observable as soon as
15 * its internal timer becomes disabled, and ignores source values while the
16 * timer is enabled. Initially, the timer is disabled. As soon as the first
17 * source value arrives, the timer is enabled. After `duration` milliseconds (or
18 * the time unit determined internally by the optional `scheduler`) has passed,
19 * the timer is disabled, then the most recent source value is emitted on the
20 * output Observable, and this process repeats for the next source value.
21 * Optionally takes a {@link SchedulerLike} for managing timers.
22 *
23 * ## Example
24 *
25 * Emit clicks at a rate of at most one click per second
26 * ```ts
27 * import { fromEvent } from 'rxjs';
28 * import { auditTime } from 'rxjs/operators';
29 *
30 * const clicks = fromEvent(document, 'click');
31 * const result = clicks.pipe(auditTime(1000));
32 * result.subscribe(x => console.log(x));
33 * ```
34 *
35 * @see {@link audit}
36 * @see {@link debounceTime}
37 * @see {@link delay}
38 * @see {@link sampleTime}
39 * @see {@link throttleTime}
40 *
41 * @param {number} duration Time to wait before emitting the most recent source
42 * value, measured in milliseconds or the time unit determined internally
43 * by the optional `scheduler`.
44 * @param {SchedulerLike} [scheduler=async] The {@link SchedulerLike} to use for
45 * managing the timers that handle the rate-limiting behavior.
46 * @return A function that returns an Observable that performs rate-limiting of
47 * emissions from the source Observable.
48 */
49export declare function auditTime<T>(duration: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>;
50//# sourceMappingURL=auditTime.d.ts.map
\No newline at end of file