Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / internal / operators / throttle.d.ts
1 import { MonoTypeOperatorFunction, SubscribableOrPromise } from '../types';
2 export interface ThrottleConfig {
3     leading?: boolean;
4     trailing?: boolean;
5 }
6 export declare const defaultThrottleConfig: ThrottleConfig;
7 /**
8  * Emits a value from the source Observable, then ignores subsequent source
9  * values for a duration determined by another Observable, then repeats this
10  * process.
11  *
12  * <span class="informal">It's like {@link throttleTime}, but the silencing
13  * duration is determined by a second Observable.</span>
14  *
15  * ![](throttle.png)
16  *
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
24  * next source value.
25  *
26  * ## Example
27  * Emit clicks at a rate of at most one click per second
28  * ```ts
29  * import { fromEvent } from 'rxjs';
30  * import { throttle } from 'rxjs/operators';
31  *
32  * const clicks = fromEvent(document, 'click');
33  * const result = clicks.pipe(throttle(ev => interval(1000)));
34  * result.subscribe(x => console.log(x));
35  * ```
36  *
37  * @see {@link audit}
38  * @see {@link debounce}
39  * @see {@link delayWhen}
40  * @see {@link sample}
41  * @see {@link throttleTime}
42  *
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.
50  * @method throttle
51  * @owner Observable
52  */
53 export declare function throttle<T>(durationSelector: (value: T) => SubscribableOrPromise<any>, config?: ThrottleConfig): MonoTypeOperatorFunction<T>;