@ahoo-wang/fetcher-react 2.6.15 → 2.6.18
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/README.md +15 -15
- package/README.zh-CN.md +11 -11
- package/dist/core/useLatest.d.ts +2 -1
- package/dist/core/useLatest.d.ts.map +1 -1
- package/dist/index.es.js +157 -2112
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -17
- package/dist/index.umd.js.map +1 -1
- package/dist/wow/index.d.ts +1 -0
- package/dist/wow/index.d.ts.map +1 -1
- package/dist/wow/useCountQuery.d.ts +23 -38
- package/dist/wow/useCountQuery.d.ts.map +1 -1
- package/dist/wow/useListQuery.d.ts +31 -57
- package/dist/wow/useListQuery.d.ts.map +1 -1
- package/dist/wow/useListStreamQuery.d.ts +31 -64
- package/dist/wow/useListStreamQuery.d.ts.map +1 -1
- package/dist/wow/usePagedQuery.d.ts +32 -57
- package/dist/wow/usePagedQuery.d.ts.map +1 -1
- package/dist/wow/useQuery.d.ts +80 -0
- package/dist/wow/useQuery.d.ts.map +1 -0
- package/dist/wow/useSingleQuery.d.ts +31 -52
- package/dist/wow/useSingleQuery.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/wow/useListQueryState.d.ts +0 -66
- package/dist/wow/useListQueryState.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -340,7 +340,7 @@ import { useListQuery } from '@ahoo-wang/fetcher-react';
|
|
|
340
340
|
const MyComponent = () => {
|
|
341
341
|
const { result, loading, error, execute, setCondition, setLimit } = useListQuery({
|
|
342
342
|
initialQuery: { condition: {}, projection: {}, sort: [], limit: 10 },
|
|
343
|
-
|
|
343
|
+
execute: async (listQuery) => {
|
|
344
344
|
// Your list fetching logic here
|
|
345
345
|
return fetchListData(listQuery);
|
|
346
346
|
},
|
|
@@ -375,7 +375,7 @@ import { useListQuery } from '@ahoo-wang/fetcher-react';
|
|
|
375
375
|
const MyComponent = () => {
|
|
376
376
|
const { result, loading, error, execute, setCondition } = useListQuery({
|
|
377
377
|
initialQuery: { condition: {}, projection: {}, sort: [], limit: 10 },
|
|
378
|
-
|
|
378
|
+
execute: async (listQuery) => fetchListData(listQuery),
|
|
379
379
|
autoExecute: true, // Automatically execute on component mount
|
|
380
380
|
});
|
|
381
381
|
|
|
@@ -413,7 +413,7 @@ const MyComponent = () => {
|
|
|
413
413
|
projection: {},
|
|
414
414
|
sort: []
|
|
415
415
|
},
|
|
416
|
-
|
|
416
|
+
execute: async (pagedQuery) => {
|
|
417
417
|
// Your paged fetching logic here
|
|
418
418
|
return fetchPagedData(pagedQuery);
|
|
419
419
|
},
|
|
@@ -430,7 +430,7 @@ const MyComponent = () => {
|
|
|
430
430
|
return (
|
|
431
431
|
<div>
|
|
432
432
|
<ul>
|
|
433
|
-
{result?.
|
|
433
|
+
{result?.list?.map((item, index) => (
|
|
434
434
|
<li key={index}>{item.name}</li>
|
|
435
435
|
))}
|
|
436
436
|
</ul>
|
|
@@ -458,7 +458,7 @@ const MyComponent = () => {
|
|
|
458
458
|
projection: {},
|
|
459
459
|
sort: []
|
|
460
460
|
},
|
|
461
|
-
|
|
461
|
+
execute: async (pagedQuery) => fetchPagedData(pagedQuery),
|
|
462
462
|
autoExecute: true, // Automatically execute on component mount
|
|
463
463
|
});
|
|
464
464
|
|
|
@@ -470,7 +470,7 @@ const MyComponent = () => {
|
|
|
470
470
|
return (
|
|
471
471
|
<div>
|
|
472
472
|
<ul>
|
|
473
|
-
{result?.
|
|
473
|
+
{result?.list?.map((item, index) => (
|
|
474
474
|
<li key={index}>{item.name}</li>
|
|
475
475
|
))}
|
|
476
476
|
</ul>
|
|
@@ -495,7 +495,7 @@ import { useSingleQuery } from '@ahoo-wang/fetcher-react';
|
|
|
495
495
|
const MyComponent = () => {
|
|
496
496
|
const { result, loading, error, execute, setCondition } = useSingleQuery({
|
|
497
497
|
initialQuery: { condition: {}, projection: {}, sort: [] },
|
|
498
|
-
|
|
498
|
+
execute: async (singleQuery) => {
|
|
499
499
|
// Your single item fetching logic here
|
|
500
500
|
return fetchSingleData(singleQuery);
|
|
501
501
|
},
|
|
@@ -526,7 +526,7 @@ import { useSingleQuery } from '@ahoo-wang/fetcher-react';
|
|
|
526
526
|
const MyComponent = () => {
|
|
527
527
|
const { result, loading, error, execute, setCondition } = useSingleQuery({
|
|
528
528
|
initialQuery: { condition: {}, projection: {}, sort: [] },
|
|
529
|
-
|
|
529
|
+
execute: async (singleQuery) => fetchSingleData(singleQuery),
|
|
530
530
|
autoExecute: true, // Automatically execute on component mount
|
|
531
531
|
});
|
|
532
532
|
|
|
@@ -552,8 +552,8 @@ import { useCountQuery } from '@ahoo-wang/fetcher-react';
|
|
|
552
552
|
|
|
553
553
|
const MyComponent = () => {
|
|
554
554
|
const { result, loading, error, execute, setCondition } = useCountQuery({
|
|
555
|
-
|
|
556
|
-
|
|
555
|
+
initialQuery: {},
|
|
556
|
+
execute: async (condition) => {
|
|
557
557
|
// Your count fetching logic here
|
|
558
558
|
return fetchCount(condition);
|
|
559
559
|
},
|
|
@@ -583,8 +583,8 @@ import { useCountQuery } from '@ahoo-wang/fetcher-react';
|
|
|
583
583
|
|
|
584
584
|
const MyComponent = () => {
|
|
585
585
|
const { result, loading, error, execute, setCondition } = useCountQuery({
|
|
586
|
-
|
|
587
|
-
|
|
586
|
+
initialQuery: {},
|
|
587
|
+
execute: async (condition) => fetchCount(condition),
|
|
588
588
|
autoExecute: true, // Automatically execute on component mount
|
|
589
589
|
});
|
|
590
590
|
|
|
@@ -611,7 +611,7 @@ import { useListStreamQuery } from '@ahoo-wang/fetcher-react';
|
|
|
611
611
|
const MyComponent = () => {
|
|
612
612
|
const { result, loading, error, execute, setCondition } = useListStreamQuery({
|
|
613
613
|
initialQuery: { condition: {}, projection: {}, sort: [], limit: 100 },
|
|
614
|
-
|
|
614
|
+
execute: async (listQuery) => {
|
|
615
615
|
// Your stream fetching logic here
|
|
616
616
|
return fetchListStream(listQuery);
|
|
617
617
|
},
|
|
@@ -655,7 +655,7 @@ import { useListStreamQuery } from '@ahoo-wang/fetcher-react';
|
|
|
655
655
|
const MyComponent = () => {
|
|
656
656
|
const { result, loading, error, execute, setCondition } = useListStreamQuery({
|
|
657
657
|
initialQuery: { condition: {}, projection: {}, sort: [], limit: 100 },
|
|
658
|
-
|
|
658
|
+
execute: async (listQuery) => fetchListStream(listQuery),
|
|
659
659
|
autoExecute: true, // Automatically execute on component mount
|
|
660
660
|
});
|
|
661
661
|
|
|
@@ -947,7 +947,7 @@ A React hook for managing count queries with state management for conditions.
|
|
|
947
947
|
|
|
948
948
|
**Parameters:**
|
|
949
949
|
|
|
950
|
-
- `options`: Configuration options including
|
|
950
|
+
- `options`: Configuration options including initialQuery and execute function
|
|
951
951
|
- `autoExecute`: Whether to automatically execute the query on component mount (defaults to false)
|
|
952
952
|
|
|
953
953
|
**Returns:**
|
package/README.zh-CN.md
CHANGED
|
@@ -94,7 +94,7 @@ import { useListQuery } from '@ahoo-wang/fetcher-react';
|
|
|
94
94
|
const MyComponent = () => {
|
|
95
95
|
const { result, loading, error, execute, setCondition } = useListQuery({
|
|
96
96
|
initialQuery: { condition: {}, projection: {}, sort: [], limit: 10 },
|
|
97
|
-
|
|
97
|
+
execute: async (listQuery) => fetchListData(listQuery),
|
|
98
98
|
autoExecute: true, // 在组件挂载时自动执行
|
|
99
99
|
});
|
|
100
100
|
|
|
@@ -330,8 +330,8 @@ import { useListQuery } from '@ahoo-wang/fetcher-react';
|
|
|
330
330
|
const MyComponent = () => {
|
|
331
331
|
const { result, loading, error, execute, setCondition, setLimit } = useListQuery({
|
|
332
332
|
initialQuery: { condition: {}, projection: {}, sort: [], limit: 10 },
|
|
333
|
-
|
|
334
|
-
//
|
|
333
|
+
execute: async (listQuery) => {
|
|
334
|
+
// Your list fetching logic here
|
|
335
335
|
return fetchListData(listQuery);
|
|
336
336
|
},
|
|
337
337
|
});
|
|
@@ -372,8 +372,8 @@ const MyComponent = () => {
|
|
|
372
372
|
projection: {},
|
|
373
373
|
sort: []
|
|
374
374
|
},
|
|
375
|
-
|
|
376
|
-
//
|
|
375
|
+
execute: async (pagedQuery) => {
|
|
376
|
+
// Your paged fetching logic here
|
|
377
377
|
return fetchPagedData(pagedQuery);
|
|
378
378
|
},
|
|
379
379
|
});
|
|
@@ -389,7 +389,7 @@ const MyComponent = () => {
|
|
|
389
389
|
return (
|
|
390
390
|
<div>
|
|
391
391
|
<ul>
|
|
392
|
-
{result?.
|
|
392
|
+
{result?.list?.map((item, index) => (
|
|
393
393
|
<li key={index}>{item.name}</li>
|
|
394
394
|
))}
|
|
395
395
|
</ul>
|
|
@@ -414,7 +414,7 @@ import { useSingleQuery } from '@ahoo-wang/fetcher-react';
|
|
|
414
414
|
const MyComponent = () => {
|
|
415
415
|
const { result, loading, error, execute, setCondition } = useSingleQuery({
|
|
416
416
|
initialQuery: { condition: {}, projection: {}, sort: [] },
|
|
417
|
-
|
|
417
|
+
execute: async (singleQuery) => {
|
|
418
418
|
// 您的单个获取逻辑
|
|
419
419
|
return fetchSingleData(singleQuery);
|
|
420
420
|
},
|
|
@@ -446,8 +446,8 @@ import { useCountQuery } from '@ahoo-wang/fetcher-react';
|
|
|
446
446
|
|
|
447
447
|
const MyComponent = () => {
|
|
448
448
|
const { result, loading, error, execute, setCondition } = useCountQuery({
|
|
449
|
-
|
|
450
|
-
|
|
449
|
+
initialQuery: {},
|
|
450
|
+
execute: async (condition) => {
|
|
451
451
|
// 您的计数获取逻辑
|
|
452
452
|
return fetchCount(condition);
|
|
453
453
|
},
|
|
@@ -480,7 +480,7 @@ import { useListStreamQuery } from '@ahoo-wang/fetcher-react';
|
|
|
480
480
|
const MyComponent = () => {
|
|
481
481
|
const { result, loading, error, execute, setCondition } = useListStreamQuery({
|
|
482
482
|
initialQuery: { condition: {}, projection: {}, sort: [], limit: 100 },
|
|
483
|
-
|
|
483
|
+
execute: async (listQuery) => {
|
|
484
484
|
// 您的流获取逻辑
|
|
485
485
|
return fetchListStream(listQuery);
|
|
486
486
|
},
|
|
@@ -768,7 +768,7 @@ function useCountQuery<FIELDS extends string = string, E = FetcherError>(
|
|
|
768
768
|
|
|
769
769
|
**参数:**
|
|
770
770
|
|
|
771
|
-
- `options`: 包含
|
|
771
|
+
- `options`: 包含 initialQuery 和 execute 函数的配置选项
|
|
772
772
|
- `autoExecute`: 是否在组件挂载时自动执行查询(默认为 false)
|
|
773
773
|
|
|
774
774
|
**返回值:**
|
package/dist/core/useLatest.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
1
2
|
/**
|
|
2
3
|
* A React hook that returns a ref containing the latest value, useful for accessing the current value in async callbacks.
|
|
3
4
|
*
|
|
@@ -28,5 +29,5 @@
|
|
|
28
29
|
* };
|
|
29
30
|
* ```
|
|
30
31
|
*/
|
|
31
|
-
export declare function useLatest<T>(value: T):
|
|
32
|
+
export declare function useLatest<T>(value: T): MutableRefObject<T>;
|
|
32
33
|
//# sourceMappingURL=useLatest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLatest.d.ts","sourceRoot":"","sources":["../../src/core/useLatest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLatest.d.ts","sourceRoot":"","sources":["../../src/core/useLatest.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAU,MAAM,OAAO,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAI1D"}
|