UNPKG

2.02 kBTypeScriptView Raw
1import { MonoTypeOperatorFunction, ObservableInput } from '../types';
2/**
3 * Ignores source values for a duration determined by another Observable, then
4 * emits the most recent value from the source Observable, then repeats this
5 * process.
6 *
7 * <span class="informal">It's like {@link auditTime}, but the silencing
8 * duration is determined by a second Observable.</span>
9 *
10 * ![](audit.svg)
11 *
12 * `audit` is similar to `throttle`, but emits the last value from the silenced
13 * time window, instead of the first value. `audit` emits the most recent value
14 * from the source Observable on the output Observable as soon as its internal
15 * timer becomes disabled, and ignores source values while the timer is enabled.
16 * Initially, the timer is disabled. As soon as the first source value arrives,
17 * the timer is enabled by calling the `durationSelector` function with the
18 * source value, which returns the "duration" Observable. When the duration
19 * Observable emits a value, the timer is disabled, then the most
20 * recent source value is emitted on the output Observable, and this process
21 * repeats for the next source value.
22 *
23 * ## Example
24 *
25 * Emit clicks at a rate of at most one click per second
26 *
27 * ```ts
28 * import { fromEvent, audit, interval } from 'rxjs';
29 *
30 * const clicks = fromEvent(document, 'click');
31 * const result = clicks.pipe(audit(ev => interval(1000)));
32 * result.subscribe(x => console.log(x));
33 * ```
34 *
35 * @see {@link auditTime}
36 * @see {@link debounce}
37 * @see {@link delayWhen}
38 * @see {@link sample}
39 * @see {@link throttle}
40 *
41 * @param durationSelector A function
42 * that receives a value from the source Observable, for computing the silencing
43 * duration, returned as an Observable or a Promise.
44 * @return A function that returns an Observable that performs rate-limiting of
45 * emissions from the source Observable.
46 */
47export declare function audit<T>(durationSelector: (value: T) => ObservableInput<any>): MonoTypeOperatorFunction<T>;
48//# sourceMappingURL=audit.d.ts.map
\No newline at end of file