@ahoo-wang/fetcher-react 2.6.12 → 2.6.15

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 CHANGED
@@ -367,6 +367,36 @@ const MyComponent = () => {
367
367
  };
368
368
  ```
369
369
 
370
+ #### Auto Execute Example
371
+
372
+ ```typescript jsx
373
+ import { useListQuery } from '@ahoo-wang/fetcher-react';
374
+
375
+ const MyComponent = () => {
376
+ const { result, loading, error, execute, setCondition } = useListQuery({
377
+ initialQuery: { condition: {}, projection: {}, sort: [], limit: 10 },
378
+ list: async (listQuery) => fetchListData(listQuery),
379
+ autoExecute: true, // Automatically execute on component mount
380
+ });
381
+
382
+ // The query will execute automatically when the component mounts
383
+ // You can still manually trigger it with execute() or update conditions
384
+
385
+ if (loading) return <div>Loading...</div>;
386
+ if (error) return <div>Error: {error.message}</div>;
387
+
388
+ return (
389
+ <div>
390
+ <ul>
391
+ {result?.map((item, index) => (
392
+ <li key={index}>{item.name}</li>
393
+ ))}
394
+ </ul>
395
+ </div>
396
+ );
397
+ };
398
+ ```
399
+
370
400
  ### usePagedQuery Hook
371
401
 
372
402
  The `usePagedQuery` hook manages paged queries with state management for conditions, projections, pagination, and
@@ -415,6 +445,46 @@ const MyComponent = () => {
415
445
  };
416
446
  ```
417
447
 
448
+ #### Auto Execute Example
449
+
450
+ ```typescript jsx
451
+ import { usePagedQuery } from '@ahoo-wang/fetcher-react';
452
+
453
+ const MyComponent = () => {
454
+ const { result, loading, error, execute, setCondition, setPagination } = usePagedQuery({
455
+ initialQuery: {
456
+ condition: {},
457
+ pagination: { index: 1, size: 10 },
458
+ projection: {},
459
+ sort: []
460
+ },
461
+ query: async (pagedQuery) => fetchPagedData(pagedQuery),
462
+ autoExecute: true, // Automatically execute on component mount
463
+ });
464
+
465
+ // The query will execute automatically when the component mounts
466
+
467
+ if (loading) return <div>Loading...</div>;
468
+ if (error) return <div>Error: {error.message}</div>;
469
+
470
+ return (
471
+ <div>
472
+ <ul>
473
+ {result?.data?.map((item, index) => (
474
+ <li key={index}>{item.name}</li>
475
+ ))}
476
+ </ul>
477
+ <button onClick={() => setPagination({ index: result?.pagination?.index! - 1, size: 10 })} disabled={result?.pagination?.index === 1}>
478
+ Previous
479
+ </button>
480
+ <button onClick={() => setPagination({ index: result?.pagination?.index! + 1, size: 10 })}>
481
+ Next
482
+ </button>
483
+ </div>
484
+ );
485
+ };
486
+ ```
487
+
418
488
  ### useSingleQuery Hook
419
489
 
420
490
  The `useSingleQuery` hook manages single item queries with state management for conditions, projections, and sorting.
@@ -448,6 +518,31 @@ const MyComponent = () => {
448
518
  };
449
519
  ```
450
520
 
521
+ #### Auto Execute Example
522
+
523
+ ```typescript jsx
524
+ import { useSingleQuery } from '@ahoo-wang/fetcher-react';
525
+
526
+ const MyComponent = () => {
527
+ const { result, loading, error, execute, setCondition } = useSingleQuery({
528
+ initialQuery: { condition: {}, projection: {}, sort: [] },
529
+ query: async (singleQuery) => fetchSingleData(singleQuery),
530
+ autoExecute: true, // Automatically execute on component mount
531
+ });
532
+
533
+ // The query will execute automatically when the component mounts
534
+
535
+ if (loading) return <div>Loading...</div>;
536
+ if (error) return <div>Error: {error.message}</div>;
537
+
538
+ return (
539
+ <div>
540
+ {result && <p>User: {result.name}</p>}
541
+ </div>
542
+ );
543
+ };
544
+ ```
545
+
451
546
  ### useCountQuery Hook
452
547
 
453
548
  The `useCountQuery` hook manages count queries with state management for conditions.
@@ -481,6 +576,31 @@ const MyComponent = () => {
481
576
  };
482
577
  ```
483
578
 
579
+ #### Auto Execute Example
580
+
581
+ ```typescript jsx
582
+ import { useCountQuery } from '@ahoo-wang/fetcher-react';
583
+
584
+ const MyComponent = () => {
585
+ const { result, loading, error, execute, setCondition } = useCountQuery({
586
+ initialCondition: {},
587
+ count: async (condition) => fetchCount(condition),
588
+ autoExecute: true, // Automatically execute on component mount
589
+ });
590
+
591
+ // The query will execute automatically when the component mounts
592
+
593
+ if (loading) return <div>Loading...</div>;
594
+ if (error) return <div>Error: {error.message}</div>;
595
+
596
+ return (
597
+ <div>
598
+ <p>Total: {result}</p>
599
+ </div>
600
+ );
601
+ };
602
+ ```
603
+
484
604
  ### useListStreamQuery Hook
485
605
 
486
606
  The `useListStreamQuery` hook manages list stream queries that return a readable stream of server-sent events.
@@ -527,12 +647,56 @@ const MyComponent = () => {
527
647
  };
528
648
  ```
529
649
 
650
+ #### Auto Execute Example
651
+
652
+ ```typescript jsx
653
+ import { useListStreamQuery } from '@ahoo-wang/fetcher-react';
654
+
655
+ const MyComponent = () => {
656
+ const { result, loading, error, execute, setCondition } = useListStreamQuery({
657
+ initialQuery: { condition: {}, projection: {}, sort: [], limit: 100 },
658
+ listStream: async (listQuery) => fetchListStream(listQuery),
659
+ autoExecute: true, // Automatically execute on component mount
660
+ });
661
+
662
+ useEffect(() => {
663
+ if (result) {
664
+ const reader = result.getReader();
665
+ const readStream = async () => {
666
+ try {
667
+ while (true) {
668
+ const { done, value } = await reader.read();
669
+ if (done) break;
670
+ console.log('Received:', value);
671
+ // Process the stream event
672
+ }
673
+ } catch (error) {
674
+ console.error('Stream error:', error);
675
+ }
676
+ };
677
+ readStream();
678
+ }
679
+ }, [result]);
680
+
681
+ // The query will execute automatically when the component mounts
682
+
683
+ if (loading) return <div>Loading...</div>;
684
+ if (error) return <div>Error: {error.message}</div>;
685
+
686
+ return (
687
+ <div>
688
+ {/* Stream is already started automatically */}
689
+ </div>
690
+ );
691
+ };
692
+ ```
693
+
530
694
  ## API Reference
531
695
 
532
696
  ### useFetcher
533
697
 
534
698
  ```typescript
535
- function useFetcher<R = unknown, E = unknown>(
699
+ function useFetcher<R = unknown, E = FetcherError>(
536
700
  options?: UseFetcherOptions<R, E> | UseFetcherOptionsSupplier<R, E>,
537
701
  ): UseFetcherReturn<R, E>;
538
702
  ```
@@ -543,7 +707,7 @@ flexible configuration.
543
707
  **Type Parameters:**
544
708
 
545
709
  - `R`: The type of the result
546
- - `E`: The type of the error (defaults to `unknown`)
710
+ - `E`: The type of the error (defaults to `FetcherError`)
547
711
 
548
712
  **Parameters:**
549
713
 
@@ -567,7 +731,7 @@ An object containing:
567
731
  ### useExecutePromise
568
732
 
569
733
  ```typescript
570
- function useExecutePromise<R = unknown, E = unknown>(
734
+ function useExecutePromise<R = unknown, E = FetcherError>(
571
735
  options?: UseExecutePromiseOptions<R, E>,
572
736
  ): UseExecutePromiseReturn<R, E>;
573
737
  ```
@@ -578,7 +742,7 @@ state options.
578
742
  **Type Parameters:**
579
743
 
580
744
  - `R`: The type of the result
581
- - `E`: The type of the error (defaults to `unknown`)
745
+ - `E`: The type of the error (defaults to `FetcherError`)
582
746
 
583
747
  **Parameters:**
584
748
 
@@ -601,7 +765,7 @@ An object containing:
601
765
  ### usePromiseState
602
766
 
603
767
  ```typescript
604
- function usePromiseState<R = unknown, E = unknown>(
768
+ function usePromiseState<R = unknown, E = FetcherError>(
605
769
  options?: UsePromiseStateOptions<R, E> | UsePromiseStateOptionsSupplier<R, E>,
606
770
  ): UsePromiseStateReturn<R, E>;
607
771
  ```
@@ -612,7 +776,7 @@ suppliers.
612
776
  **Type Parameters:**
613
777
 
614
778
  - `R`: The type of the result
615
- - `E`: The type of the error (defaults to `unknown`)
779
+ - `E`: The type of the error (defaults to `FetcherError`)
616
780
 
617
781
  **Parameters:**
618
782
 
@@ -694,7 +858,7 @@ A React hook that provides state management for a KeyStorage instance.
694
858
  ### useListQuery
695
859
 
696
860
  ```typescript
697
- function useListQuery<R, FIELDS extends string = string, E = unknown>(
861
+ function useListQuery<R, FIELDS extends string = string, E = FetcherError>(
698
862
  options: UseListQueryOptions<R, FIELDS, E>,
699
863
  ): UseListQueryReturn<R, FIELDS, E>;
700
864
  ```
@@ -705,7 +869,7 @@ A React hook for managing list queries with state management for conditions, pro
705
869
 
706
870
  - `R`: The type of the result items in the list
707
871
  - `FIELDS`: The type of the fields used in conditions and projections
708
- - `E`: The type of the error (defaults to `unknown`)
872
+ - `E`: The type of the error (defaults to `FetcherError`)
709
873
 
710
874
  **Parameters:**
711
875
 
@@ -719,7 +883,7 @@ An object containing promise state, execute function, and setters for condition,
719
883
  ### usePagedQuery
720
884
 
721
885
  ```typescript
722
- function usePagedQuery<R, FIELDS extends string = string, E = unknown>(
886
+ function usePagedQuery<R, FIELDS extends string = string, E = FetcherError>(
723
887
  options: UsePagedQueryOptions<R, FIELDS, E>,
724
888
  ): UsePagedQueryReturn<R, FIELDS, E>;
725
889
  ```
@@ -730,7 +894,7 @@ A React hook for managing paged queries with state management for conditions, pr
730
894
 
731
895
  - `R`: The type of the result items in the paged list
732
896
  - `FIELDS`: The type of the fields used in conditions and projections
733
- - `E`: The type of the error (defaults to `unknown`)
897
+ - `E`: The type of the error (defaults to `FetcherError`)
734
898
 
735
899
  **Parameters:**
736
900
 
@@ -744,7 +908,7 @@ An object containing promise state, execute function, and setters for condition,
744
908
  ### useSingleQuery
745
909
 
746
910
  ```typescript
747
- function useSingleQuery<R, FIELDS extends string = string, E = unknown>(
911
+ function useSingleQuery<R, FIELDS extends string = string, E = FetcherError>(
748
912
  options: UseSingleQueryOptions<R, FIELDS, E>,
749
913
  ): UseSingleQueryReturn<R, FIELDS, E>;
750
914
  ```
@@ -755,7 +919,7 @@ A React hook for managing single queries with state management for conditions, p
755
919
 
756
920
  - `R`: The type of the result
757
921
  - `FIELDS`: The type of the fields used in conditions and projections
758
- - `E`: The type of the error (defaults to `unknown`)
922
+ - `E`: The type of the error (defaults to `FetcherError`)
759
923
 
760
924
  **Parameters:**
761
925
 
@@ -769,7 +933,7 @@ An object containing promise state, execute function, and setters for condition,
769
933
  ### useCountQuery
770
934
 
771
935
  ```typescript
772
- function useCountQuery<FIELDS extends string = string, E = unknown>(
936
+ function useCountQuery<FIELDS extends string = string, E = FetcherError>(
773
937
  options: UseCountQueryOptions<FIELDS, E>,
774
938
  ): UseCountQueryReturn<FIELDS, E>;
775
939
  ```
@@ -779,7 +943,7 @@ A React hook for managing count queries with state management for conditions.
779
943
  **Type Parameters:**
780
944
 
781
945
  - `FIELDS`: The type of the fields used in conditions
782
- - `E`: The type of the error (defaults to `unknown`)
946
+ - `E`: The type of the error (defaults to `FetcherError`)
783
947
 
784
948
  **Parameters:**
785
949
 
@@ -793,7 +957,11 @@ An object containing promise state, execute function, and setter for condition.
793
957
  ### useListStreamQuery
794
958
 
795
959
  ```typescript
796
- function useListStreamQuery<R, FIELDS extends string = string, E = unknown>(
960
+ function useListStreamQuery<
961
+ R,
962
+ FIELDS extends string = string,
963
+ E = FetcherError,
964
+ >(
797
965
  options: UseListStreamQueryOptions<R, FIELDS, E>,
798
966
  ): UseListStreamQueryReturn<R, FIELDS, E>;
799
967
  ```
@@ -805,7 +973,7 @@ Returns a readable stream of JSON server-sent events.
805
973
 
806
974
  - `R`: The type of the result items in the stream events
807
975
  - `FIELDS`: The type of the fields used in conditions and projections
808
- - `E`: The type of the error (defaults to `unknown`)
976
+ - `E`: The type of the error (defaults to `FetcherError`)
809
977
 
810
978
  **Parameters:**
811
979
 
package/README.zh-CN.md CHANGED
@@ -531,7 +531,7 @@ function useFetcher<R = unknown, E = unknown>(
531
531
  **类型参数:**
532
532
 
533
533
  - `R`: 结果的类型
534
- - `E`: 错误的类型(默认为 `unknown`)
534
+ - `E`: 错误的类型(默认为 `FetcherError`)
535
535
 
536
536
  **参数:**
537
537
 
@@ -565,7 +565,7 @@ function useExecutePromise<R = unknown, E = unknown>(
565
565
  **类型参数:**
566
566
 
567
567
  - `R`: 结果的类型
568
- - `E`: 错误的类型(默认为 `unknown`)
568
+ - `E`: 错误的类型(默认为 `FetcherError`)
569
569
 
570
570
  **参数:**
571
571
 
@@ -598,7 +598,7 @@ function usePromiseState<R = unknown, E = unknown>(
598
598
  **类型参数:**
599
599
 
600
600
  - `R`: 结果的类型
601
- - `E`: 错误的类型(默认为 `unknown`)
601
+ - `E`: 错误的类型(默认为 `FetcherError`)
602
602
 
603
603
  **参数:**
604
604
 
@@ -679,7 +679,7 @@ function useKeyStorage<T>(
679
679
  ### useListQuery
680
680
 
681
681
  ```typescript
682
- function useListQuery<R, FIELDS extends string = string, E = unknown>(
682
+ function useListQuery<R, FIELDS extends string = string, E = FetcherError>(
683
683
  options: UseListQueryOptions<R, FIELDS, E>,
684
684
  ): UseListQueryReturn<R, FIELDS, E>;
685
685
  ```
@@ -690,7 +690,7 @@ function useListQuery<R, FIELDS extends string = string, E = unknown>(
690
690
 
691
691
  - `R`: 列表中结果项的类型
692
692
  - `FIELDS`: 用于条件和投影的字段类型
693
- - `E`: 错误的类型(默认为 `unknown`)
693
+ - `E`: 错误的类型(默认为 `FetcherError`)
694
694
 
695
695
  **参数:**
696
696
 
@@ -715,7 +715,7 @@ function usePagedQuery<R, FIELDS extends string = string, E = unknown>(
715
715
 
716
716
  - `R`: 分页列表中结果项的类型
717
717
  - `FIELDS`: 用于条件和投影的字段类型
718
- - `E`: 错误的类型(默认为 `unknown`)
718
+ - `E`: 错误的类型(默认为 `FetcherError`)
719
719
 
720
720
  **参数:**
721
721
 
@@ -740,7 +740,7 @@ function useSingleQuery<R, FIELDS extends string = string, E = unknown>(
740
740
 
741
741
  - `R`: 结果的类型
742
742
  - `FIELDS`: 用于条件和投影的字段类型
743
- - `E`: 错误的类型(默认为 `unknown`)
743
+ - `E`: 错误的类型(默认为 `FetcherError`)
744
744
 
745
745
  **参数:**
746
746
 
@@ -754,7 +754,7 @@ function useSingleQuery<R, FIELDS extends string = string, E = unknown>(
754
754
  ### useCountQuery
755
755
 
756
756
  ```typescript
757
- function useCountQuery<FIELDS extends string = string, E = unknown>(
757
+ function useCountQuery<FIELDS extends string = string, E = FetcherError>(
758
758
  options: UseCountQueryOptions<FIELDS, E>,
759
759
  ): UseCountQueryReturn<FIELDS, E>;
760
760
  ```
@@ -764,7 +764,7 @@ function useCountQuery<FIELDS extends string = string, E = unknown>(
764
764
  **类型参数:**
765
765
 
766
766
  - `FIELDS`: 用于条件的字段类型
767
- - `E`: 错误的类型(默认为 `unknown`)
767
+ - `E`: 错误的类型(默认为 `FetcherError`)
768
768
 
769
769
  **参数:**
770
770
 
@@ -778,7 +778,11 @@ function useCountQuery<FIELDS extends string = string, E = unknown>(
778
778
  ### useListStreamQuery
779
779
 
780
780
  ```typescript
781
- function useListStreamQuery<R, FIELDS extends string = string, E = unknown>(
781
+ function useListStreamQuery<
782
+ R,
783
+ FIELDS extends string = string,
784
+ E = FetcherError,
785
+ >(
782
786
  options: UseListStreamQueryOptions<R, FIELDS, E>,
783
787
  ): UseListStreamQueryReturn<R, FIELDS, E>;
784
788
  ```
@@ -789,7 +793,7 @@ function useListStreamQuery<R, FIELDS extends string = string, E = unknown>(
789
793
 
790
794
  - `R`: 流事件中结果项的类型
791
795
  - `FIELDS`: 用于条件和投影的字段类型
792
- - `E`: 错误的类型(默认为 `unknown`)
796
+ - `E`: 错误的类型(默认为 `FetcherError`)
793
797
 
794
798
  **参数:**
795
799
 
@@ -1,4 +1,5 @@
1
1
  import { PromiseState, UsePromiseStateOptions } from './usePromiseState';
2
+ import { FetcherError } from '@ahoo-wang/fetcher';
2
3
  export interface UseExecutePromiseOptions<R, E = unknown> extends UsePromiseStateOptions<R, E> {
3
4
  /**
4
5
  * Whether to propagate errors thrown by the promise.
@@ -16,7 +17,7 @@ export type PromiseSupplier<R> = () => Promise<R>;
16
17
  * Interface defining the return type of useExecutePromise hook
17
18
  * @template R - The type of the result value
18
19
  */
19
- export interface UseExecutePromiseReturn<R, E = unknown> extends PromiseState<R, E> {
20
+ export interface UseExecutePromiseReturn<R, E = FetcherError> extends PromiseState<R, E> {
20
21
  /**
21
22
  * Function to execute a promise supplier or promise.
22
23
  * Returns a promise that resolves to the result on success, or the error if propagateError is false.
@@ -72,5 +73,5 @@ export interface UseExecutePromiseReturn<R, E = unknown> extends PromiseState<R,
72
73
  * }
73
74
  * ```
74
75
  */
75
- export declare function useExecutePromise<R = unknown, E = unknown>(options?: UseExecutePromiseOptions<R, E>): UseExecutePromiseReturn<R, E>;
76
+ export declare function useExecutePromise<R = unknown, E = FetcherError>(options?: UseExecutePromiseOptions<R, E>): UseExecutePromiseReturn<R, E>;
76
77
  //# sourceMappingURL=useExecutePromise.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useExecutePromise.d.ts","sourceRoot":"","sources":["../../src/core/useExecutePromise.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,YAAY,EACZ,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,WAAW,wBAAwB,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,CACtD,SAAQ,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC;IACpC;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,CACrD,SAAQ,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1B;;;OAGG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACpE,oDAAoD;IACpD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EACxD,OAAO,CAAC,EAAE,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,GACvC,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,CA0D/B"}
1
+ {"version":3,"file":"useExecutePromise.d.ts","sourceRoot":"","sources":["../../src/core/useExecutePromise.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,YAAY,EACZ,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,wBAAwB,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,CACtD,SAAQ,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC;IACpC;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,EAAE,CAAC,GAAG,YAAY,CAC1D,SAAQ,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1B;;;OAGG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACpE,oDAAoD;IACpD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,YAAY,EAC7D,OAAO,CAAC,EAAE,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,GACvC,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,CA0D/B"}
@@ -1,3 +1,4 @@
1
+ import { FetcherError } from '@ahoo-wang/fetcher';
1
2
  /**
2
3
  * Enumeration of possible promise execution states
3
4
  */
@@ -39,7 +40,7 @@ export interface PromiseStateCallbacks<R, E = unknown> {
39
40
  * };
40
41
  * ```
41
42
  */
42
- export interface UsePromiseStateOptions<R, E = unknown> extends PromiseStateCallbacks<R, E> {
43
+ export interface UsePromiseStateOptions<R, E = FetcherError> extends PromiseStateCallbacks<R, E> {
43
44
  /** Initial status, defaults to IDLE */
44
45
  initialStatus?: PromiseStatus;
45
46
  }
@@ -47,7 +48,7 @@ export interface UsePromiseStateOptions<R, E = unknown> extends PromiseStateCall
47
48
  * Return type for usePromiseState hook
48
49
  * @template R - The type of result
49
50
  */
50
- export interface UsePromiseStateReturn<R, E = unknown> extends PromiseState<R, E> {
51
+ export interface UsePromiseStateReturn<R, E = FetcherError> extends PromiseState<R, E> {
51
52
  /** Set status to LOADING */
52
53
  setLoading: () => void;
53
54
  /** Set status to SUCCESS with result */
@@ -87,5 +88,5 @@ export interface UsePromiseStateReturn<R, E = unknown> extends PromiseState<R, E
87
88
  * }
88
89
  * ```
89
90
  */
90
- export declare function usePromiseState<R = unknown, E = unknown>(options?: UsePromiseStateOptions<R, E>): UsePromiseStateReturn<R, E>;
91
+ export declare function usePromiseState<R = unknown, E = FetcherError>(options?: UsePromiseStateOptions<R, E>): UsePromiseStateReturn<R, E>;
91
92
  //# sourceMappingURL=usePromiseState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePromiseState.d.ts","sourceRoot":"","sources":["../../src/core/usePromiseState.ts"],"names":[],"mappings":"AAiBA;;GAEG;AACH,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO;IAC1C,oCAAoC;IACpC,MAAM,EAAE,aAAa,CAAC;IACtB,qCAAqC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,uBAAuB;IACvB,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC;IACtB,sBAAsB;IACtB,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO;IACnD,iDAAiD;IACjD,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CA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