@unitedstatespowersquadrons/components 1.2.26 → 1.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Reducer/wrapDispatch.tsx +9 -4
- package/package.json +1 -1
package/Reducer/wrapDispatch.tsx
CHANGED
|
@@ -21,7 +21,7 @@ export default function wrapDispatch<
|
|
|
21
21
|
handler: DispatchHandler<A>,
|
|
22
22
|
skipDebounce?: boolean
|
|
23
23
|
): DispatchFunc<A> {
|
|
24
|
-
const updateDebounceTime =
|
|
24
|
+
const updateDebounceTime = (("testEnv" in window) && window.testEnv) ? 50 : 250;
|
|
25
25
|
|
|
26
26
|
const updateHandler = async (action: A, signal: AbortSignal) => {
|
|
27
27
|
const handlerData = handler(action);
|
|
@@ -65,14 +65,19 @@ export default function wrapDispatch<
|
|
|
65
65
|
if (timer) clearTimeout(timer);
|
|
66
66
|
delete timers[timeoutKey];
|
|
67
67
|
const oldAbortController = abortControllers[timeoutKey];
|
|
68
|
-
if (oldAbortController) oldAbortController.abort();
|
|
68
|
+
if (oldAbortController && !skipDebounce) oldAbortController.abort();
|
|
69
69
|
delete abortControllers[timeoutKey];
|
|
70
70
|
|
|
71
71
|
// Make request
|
|
72
72
|
const abortController = abortControllers[timeoutKey] = new AbortController();
|
|
73
73
|
const signal = abortController.signal;
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
if (skipDebounce) {
|
|
75
76
|
void updateHandler(action, signal);
|
|
76
|
-
}
|
|
77
|
+
} else {
|
|
78
|
+
timers[timeoutKey] = setTimeout(() => {
|
|
79
|
+
void updateHandler(action, signal);
|
|
80
|
+
}, updateDebounceTime);
|
|
81
|
+
}
|
|
77
82
|
};
|
|
78
83
|
}
|