@unitedstatespowersquadrons/components 1.2.26-1 → 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.
@@ -19,9 +19,9 @@ export default function wrapDispatch<
19
19
  dispatch: DispatchFunc<A>,
20
20
  appActionTypes: AppActionType<A>[],
21
21
  handler: DispatchHandler<A>,
22
- debounce?: boolean
22
+ skipDebounce?: boolean
23
23
  ): DispatchFunc<A> {
24
- const updateDebounceTime = debounce ? ((("testEnv" in window) && window.testEnv) ? 50 : 250) : 0;
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
- timers[timeoutKey] = setTimeout(() => {
74
+
75
+ if (skipDebounce) {
75
76
  void updateHandler(action, signal);
76
- }, updateDebounceTime);
77
+ } else {
78
+ timers[timeoutKey] = setTimeout(() => {
79
+ void updateHandler(action, signal);
80
+ }, updateDebounceTime);
81
+ }
77
82
  };
78
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unitedstatespowersquadrons/components",
3
- "version": "1.2.26-1",
3
+ "version": "1.2.27",
4
4
  "description": "USPS shared React components library",
5
5
  "main": "index.tsx",
6
6
  "scripts": {