1 | import { LodashDecorator } from './factory';
|
2 | import { DebounceOptions } from './shared';
|
3 | declare const decorator: (...args: any[]) => LodashDecorator;
|
4 | /**
|
5 | * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked.
|
6 | * The debounced function comes with a cancel method to cancel delayed func invocations and a flush method to immediately invoke them.
|
7 | * Provide options to indicate whether func should be invoked on the leading and/or trailing edge of the wait timeout. The func is invoked with the last arguments provided to the debounced function.
|
8 | * Subsequent calls to the debounced function return the result of the last func invocation.
|
9 | *
|
10 | * Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only if the debounced function is invoked more than once during the wait timeout.
|
11 | *
|
12 | * If wait is 0 and leading is false, func invocation is deferred until to the next tick, similar to setTimeout with a timeout of 0.
|
13 | *
|
14 | * @param {number} [wait=0] The number in milliseconds to delay.
|
15 | * @param {DebounceOptions} [options] The options object.
|
16 | * @example
|
17 | *
|
18 | * class MyClass {
|
19 | * value = 100;
|
20 | *
|
21 | * @Debounce(10)
|
22 | * add(a) {
|
23 | * this.value += a;
|
24 | * }
|
25 | * }
|
26 | *
|
27 | * const myClass = new MyClass();
|
28 | *
|
29 | * myClass.add(10);
|
30 | * myClass.add(50);
|
31 | * myClass.add(20);
|
32 | *
|
33 | * myClass.value; // => 100;
|
34 | *
|
35 | * setTimeout(() => {
|
36 | * myClass.value; // => 120;
|
37 | * }, 11);
|
38 | */
|
39 | export declare function Debounce(wait?: number, options?: DebounceOptions): LodashDecorator;
|
40 | export { Debounce as debounce };
|
41 | export default decorator;
|