api-core-lib 12.0.18 → 12.0.20
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/dist/client.cjs +21 -9
- package/dist/client.js +21 -9
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -710,20 +710,32 @@ function useApiActionState(actionConfig, cacheKey, execute, input, enabled) {
|
|
|
710
710
|
getClientSnapshot,
|
|
711
711
|
getServerSnapshot
|
|
712
712
|
);
|
|
713
|
+
const inputRef = (0, import_react4.useRef)(input);
|
|
714
|
+
(0, import_react4.useEffect)(() => {
|
|
715
|
+
inputRef.current = input;
|
|
716
|
+
}, [input]);
|
|
713
717
|
const refetch = (0, import_react4.useCallback)(() => {
|
|
714
|
-
execute(
|
|
715
|
-
}, [execute
|
|
716
|
-
const
|
|
718
|
+
execute(inputRef.current);
|
|
719
|
+
}, [execute]);
|
|
720
|
+
const previousInput = (0, import_react4.useRef)(JSON.stringify(input));
|
|
717
721
|
(0, import_react4.useEffect)(() => {
|
|
718
|
-
|
|
719
|
-
|
|
722
|
+
const currentInputString = JSON.stringify(input);
|
|
723
|
+
if (previousInput.current === currentInputString) {
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
if (enabled && state.called) {
|
|
727
|
+
console.log("[Query Changed] Input changed, refetching...");
|
|
728
|
+
refetch();
|
|
729
|
+
}
|
|
730
|
+
previousInput.current = currentInputString;
|
|
731
|
+
}, [input, enabled, state.called, refetch]);
|
|
720
732
|
(0, import_react4.useEffect)(() => {
|
|
721
733
|
if (enabled && actionConfig.autoFetch && !state.called && !state.loading) {
|
|
722
|
-
|
|
734
|
+
refetch();
|
|
723
735
|
} else if (enabled && state.isStale && !state.loading) {
|
|
724
|
-
|
|
736
|
+
refetch();
|
|
725
737
|
}
|
|
726
|
-
}, [enabled, state.isStale, state.loading, state.called, actionConfig.autoFetch]);
|
|
738
|
+
}, [enabled, state.isStale, state.loading, state.called, actionConfig.autoFetch, refetch]);
|
|
727
739
|
return state;
|
|
728
740
|
}
|
|
729
741
|
function useModuleContext() {
|
|
@@ -774,7 +786,7 @@ function useApiModule(axiosInstance, moduleConfig, options = {}) {
|
|
|
774
786
|
body: input,
|
|
775
787
|
config: options2.config
|
|
776
788
|
});
|
|
777
|
-
console.log("[API Result]", result);
|
|
789
|
+
console.log("[API Result execute]", result);
|
|
778
790
|
if (shouldCache) {
|
|
779
791
|
globalStateManager.setState(cacheKey, (prev) => ({
|
|
780
792
|
...prev,
|
package/dist/client.js
CHANGED
|
@@ -671,20 +671,32 @@ function useApiActionState(actionConfig, cacheKey, execute, input, enabled) {
|
|
|
671
671
|
getClientSnapshot,
|
|
672
672
|
getServerSnapshot
|
|
673
673
|
);
|
|
674
|
+
const inputRef = useRef4(input);
|
|
675
|
+
useEffect4(() => {
|
|
676
|
+
inputRef.current = input;
|
|
677
|
+
}, [input]);
|
|
674
678
|
const refetch = useCallback3(() => {
|
|
675
|
-
execute(
|
|
676
|
-
}, [execute
|
|
677
|
-
const
|
|
679
|
+
execute(inputRef.current);
|
|
680
|
+
}, [execute]);
|
|
681
|
+
const previousInput = useRef4(JSON.stringify(input));
|
|
678
682
|
useEffect4(() => {
|
|
679
|
-
|
|
680
|
-
|
|
683
|
+
const currentInputString = JSON.stringify(input);
|
|
684
|
+
if (previousInput.current === currentInputString) {
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
if (enabled && state.called) {
|
|
688
|
+
console.log("[Query Changed] Input changed, refetching...");
|
|
689
|
+
refetch();
|
|
690
|
+
}
|
|
691
|
+
previousInput.current = currentInputString;
|
|
692
|
+
}, [input, enabled, state.called, refetch]);
|
|
681
693
|
useEffect4(() => {
|
|
682
694
|
if (enabled && actionConfig.autoFetch && !state.called && !state.loading) {
|
|
683
|
-
|
|
695
|
+
refetch();
|
|
684
696
|
} else if (enabled && state.isStale && !state.loading) {
|
|
685
|
-
|
|
697
|
+
refetch();
|
|
686
698
|
}
|
|
687
|
-
}, [enabled, state.isStale, state.loading, state.called, actionConfig.autoFetch]);
|
|
699
|
+
}, [enabled, state.isStale, state.loading, state.called, actionConfig.autoFetch, refetch]);
|
|
688
700
|
return state;
|
|
689
701
|
}
|
|
690
702
|
function useModuleContext() {
|
|
@@ -735,7 +747,7 @@ function useApiModule(axiosInstance, moduleConfig, options = {}) {
|
|
|
735
747
|
body: input,
|
|
736
748
|
config: options2.config
|
|
737
749
|
});
|
|
738
|
-
console.log("[API Result]", result);
|
|
750
|
+
console.log("[API Result execute]", result);
|
|
739
751
|
if (shouldCache) {
|
|
740
752
|
globalStateManager.setState(cacheKey, (prev) => ({
|
|
741
753
|
...prev,
|