1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var debounce = require("lodash/debounce");
|
4 | var factory_1 = require("./factory");
|
5 | var applicators_1 = require("./applicators");
|
6 | var decorator = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(debounce, new applicators_1.PreValueApplicator()));
|
7 | /**
|
8 | * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked.
|
9 | * The debounced function comes with a cancel method to cancel delayed func invocations and a flush method to immediately invoke them.
|
10 | * 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.
|
11 | * Subsequent calls to the debounced function return the result of the last func invocation.
|
12 | *
|
13 | * The debounce state is shared across all instances of the class.
|
14 | *
|
15 | * 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.
|
16 | *
|
17 | * 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.
|
18 | *
|
19 | * @param {number} [wait=0] The number in milliseconds to delay.
|
20 | * @param {DebounceOptions} [options] The options object.
|
21 | * @example
|
22 | *
|
23 | * class MyClass {
|
24 | * value = 100;
|
25 | *
|
26 | * @DebounceAll(10)
|
27 | * add(a) {
|
28 | * this.value += a;
|
29 | * }
|
30 | * }
|
31 | *
|
32 | * const myClass = new MyClass();
|
33 | *
|
34 | * myClass.add(10);
|
35 | * myClass.add(50);
|
36 | * myClass.add(20);
|
37 | *
|
38 | * myClass.value; // => 100;
|
39 | *
|
40 | * setTimeout(() => {
|
41 | * myClass.value; // => 120;
|
42 | * }, 11);
|
43 | */
|
44 | function DebounceAll(wait, options) {
|
45 | return decorator(wait, options);
|
46 | }
|
47 | exports.DebounceAll = DebounceAll;
|
48 | exports.debounceAll = DebounceAll;
|
49 | exports.default = decorator;
|
50 | //# sourceMappingURL=debounceAll.js.map |
\ | No newline at end of file |