@ahoo-wang/fetcher-react 3.4.2 → 3.4.5

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.
@@ -2,7 +2,12 @@ import { FetcherError } from '@ahoo-wang/fetcher';
2
2
  import { DebounceCapable, UseDebouncedCallbackReturn } from '../../core';
3
3
  import { UseFetcherQueryOptions, UseFetcherQueryReturn } from '../useFetcherQuery';
4
4
  /**
5
- * Configuration options for the useDebouncedFetcherQuery hook
5
+ * Configuration options for the useDebouncedFetcherQuery hook.
6
+ *
7
+ * Extends UseFetcherQueryOptions with DebounceCapable to provide debouncing functionality.
8
+ * The hook will automatically debounce fetcher query executions to prevent excessive API calls.
9
+ * Note that autoExecute is overridden internally to false to ensure proper debouncing behavior.
10
+ *
6
11
  * @template Q - The type of the query parameters
7
12
  * @template R - The type of the result value
8
13
  * @template E - The type of the error value (defaults to FetcherError)
@@ -10,7 +15,12 @@ import { UseFetcherQueryOptions, UseFetcherQueryReturn } from '../useFetcherQuer
10
15
  export interface UseDebouncedFetcherQueryOptions<Q, R, E = FetcherError> extends UseFetcherQueryOptions<Q, R, E>, DebounceCapable {
11
16
  }
12
17
  /**
13
- * Return type of the useDebouncedFetcherQuery hook
18
+ * Return type of the useDebouncedFetcherQuery hook.
19
+ *
20
+ * Omits the original 'execute' method from UseFetcherQueryReturn and replaces it with
21
+ * debounced execution methods from UseDebouncedCallbackReturn. Uses a custom setQuery function
22
+ * that respects the original autoExecute setting.
23
+ *
14
24
  * @template Q - The type of the query parameters
15
25
  * @template R - The type of the result value
16
26
  * @template E - The type of the error value (defaults to FetcherError)
@@ -18,19 +28,21 @@ export interface UseDebouncedFetcherQueryOptions<Q, R, E = FetcherError> extends
18
28
  export interface UseDebouncedFetcherQueryReturn<Q, R, E = FetcherError> extends Omit<UseFetcherQueryReturn<Q, R, E>, 'execute'>, UseDebouncedCallbackReturn<UseFetcherQueryReturn<Q, R, E>['execute']> {
19
29
  }
20
30
  /**
21
- * A React hook for managing debounced query-based HTTP requests with automatic execution
31
+ * A React hook for managing debounced query-based HTTP requests with automatic execution.
22
32
  *
23
- * This hook combines the fetcher query functionality with debouncing to provide
24
- * a convenient way to make POST requests where query parameters are sent as the request body,
25
- * with built-in debouncing to prevent excessive API calls during rapid user interactions.
33
+ * This hook combines fetcher query functionality with debouncing to provide a convenient way to
34
+ * make POST requests where query parameters are sent as the request body, while preventing
35
+ * excessive API calls during rapid user interactions.
26
36
  *
27
- * The hook supports automatic execution on mount and when query parameters change,
28
- * but wraps the execution in a debounced callback to optimize performance.
37
+ * The hook supports automatic execution on mount and when query parameters change, but wraps
38
+ * the execution in a debounced callback to optimize performance. Internally, it overrides
39
+ * autoExecute to false and implements custom logic to respect the original autoExecute setting.
40
+ * When autoExecute is enabled, queries triggered by setQuery will also be debounced.
29
41
  *
30
42
  * @template Q - The type of the query parameters
31
43
  * @template R - The type of the result value
32
44
  * @template E - The type of the error value (defaults to FetcherError)
33
- * @param options - Configuration options for the hook
45
+ * @param options - Configuration options for the hook, including url, initialQuery, and debounce settings
34
46
  * @returns An object containing fetcher state, query management functions, and debounced execution controls
35
47
  *
36
48
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"useDebouncedFetcherQuery.d.ts","sourceRoot":"","sources":["../../../src/wow/debounce/useDebouncedFetcherQuery.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,eAAe,EAEf,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAEL,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,WAAW,+BAA+B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,YAAY,CACrE,SAAQ,sBAAsB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,eAAe;CAAG;AAE7D;;;;;GAKG;AACH,MAAM,WAAW,8B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AC/C,0BAA0B,CAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;CAAG;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,YAAY,EAC7D,OAAO,EAAE,+BAA+B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAChD,8BAA8B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CA+DzC"}
@@ -69,7 +69,7 @@ export interface UseDebouncedQueryReturn<Q, R, E = FetcherError> extends Omit<Us
69
69
  * return response.json();
70
70
  * },
71
71
  * debounce: { delay: 300 }, // Debounce for 300ms
72
- * autoExecute: false, // Don't execute on mount
72
+ * autoExecute: false,
73
73
  * });
74
74
  *
75
75
  * const handleSearch = (keyword: string) => {
@@ -1 +1 @@
1
- {"version":3,"file":"useDebouncedQuery.d.ts","sourceRoot":"","sources":["../../../src/wow/debounce/useDebouncedQuery.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAY,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EACL,eAAe,EAEf,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAGpB;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,YAAY,CAC9D,SAAQ,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,eAAe;CAAG;AAEtD;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,YAAY,CAC7D,SACE,IAAI,CAAC,cAAc,CAAC,CAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,YAAY,EACtD,OAAO,EAAE,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACzC,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CA4DlC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahoo-wang/fetcher-react",
3
- "version": "3.4.2",
3
+ "version": "3.4.5",
4
4
  "description": "React integration for Fetcher HTTP client. Provides React Hooks and components for seamless data fetching with automatic re-rendering and loading states.",
5
5
  "keywords": [
6
6
  "fetch",