1 import { MonoTypeOperatorFunction, SubscribableOrPromise } from '../types';
2 export interface ThrottleConfig {
6 export declare const defaultThrottleConfig: ThrottleConfig;
8 * Emits a value from the source Observable, then ignores subsequent source
9 * values for a duration determined by another Observable, then repeats this
12 * <span class="informal">It's like {@link throttleTime}, but the silencing
13 * duration is determined by a second Observable.</span>
17 * `throttle` emits the source Observable values on the output Observable
18 * when its internal timer is disabled, and ignores source values when the timer
19 * is enabled. Initially, the timer is disabled. As soon as the first source
20 * value arrives, it is forwarded to the output Observable, and then the timer
21 * is enabled by calling the `durationSelector` function with the source value,
22 * which returns the "duration" Observable. When the duration Observable emits a
23 * value or completes, the timer is disabled, and this process repeats for the
27 * Emit clicks at a rate of at most one click per second
29 * import { fromEvent } from 'rxjs';
30 * import { throttle } from 'rxjs/operators';
32 * const clicks = fromEvent(document, 'click');
33 * const result = clicks.pipe(throttle(ev => interval(1000)));
34 * result.subscribe(x => console.log(x));
38 * @see {@link debounce}
39 * @see {@link delayWhen}
41 * @see {@link throttleTime}
43 * @param {function(value: T): SubscribableOrPromise} durationSelector A function
44 * that receives a value from the source Observable, for computing the silencing
45 * duration for each source value, returned as an Observable or a Promise.
46 * @param {Object} config a configuration object to define `leading` and `trailing` behavior. Defaults
47 * to `{ leading: true, trailing: false }`.
48 * @return {Observable<T>} An Observable that performs the throttle operation to
49 * limit the rate of emissions from the source.
53 export declare function throttle<T>(durationSelector: (value: T) => SubscribableOrPromise<any>, config?: ThrottleConfig): MonoTypeOperatorFunction<T>;