api-core-lib 12.0.20 → 12.0.21

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 CHANGED
@@ -717,25 +717,20 @@ function useApiActionState(actionConfig, cacheKey, execute, input, enabled) {
717
717
  const refetch = (0, import_react4.useCallback)(() => {
718
718
  execute(inputRef.current);
719
719
  }, [execute]);
720
- const previousInput = (0, import_react4.useRef)(JSON.stringify(input));
720
+ const prevCacheKeyRef = (0, import_react4.useRef)(cacheKey);
721
721
  (0, import_react4.useEffect)(() => {
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...");
722
+ if (prevCacheKeyRef.current !== cacheKey && enabled && state.called) {
723
+ console.log(`[Cache Key Changed] from ${prevCacheKeyRef.current} to ${cacheKey}. Refetching...`);
728
724
  refetch();
729
- }
730
- previousInput.current = currentInputString;
731
- }, [input, enabled, state.called, refetch]);
732
- (0, import_react4.useEffect)(() => {
733
- if (enabled && actionConfig.autoFetch && !state.called && !state.loading) {
725
+ } else if (enabled && actionConfig.autoFetch && !state.called && !state.loading) {
726
+ console.log(`[Auto Fetch] for ${cacheKey}. Fetching...`);
734
727
  refetch();
735
728
  } else if (enabled && state.isStale && !state.loading) {
729
+ console.log(`[Stale State] for ${cacheKey}. Refetching...`);
736
730
  refetch();
737
731
  }
738
- }, [enabled, state.isStale, state.loading, state.called, actionConfig.autoFetch, refetch]);
732
+ prevCacheKeyRef.current = cacheKey;
733
+ }, [cacheKey, enabled, state.isStale, state.loading, state.called, actionConfig.autoFetch, refetch]);
739
734
  return state;
740
735
  }
741
736
  function useModuleContext() {
package/dist/client.js CHANGED
@@ -678,25 +678,20 @@ function useApiActionState(actionConfig, cacheKey, execute, input, enabled) {
678
678
  const refetch = useCallback3(() => {
679
679
  execute(inputRef.current);
680
680
  }, [execute]);
681
- const previousInput = useRef4(JSON.stringify(input));
681
+ const prevCacheKeyRef = useRef4(cacheKey);
682
682
  useEffect4(() => {
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...");
683
+ if (prevCacheKeyRef.current !== cacheKey && enabled && state.called) {
684
+ console.log(`[Cache Key Changed] from ${prevCacheKeyRef.current} to ${cacheKey}. Refetching...`);
689
685
  refetch();
690
- }
691
- previousInput.current = currentInputString;
692
- }, [input, enabled, state.called, refetch]);
693
- useEffect4(() => {
694
- if (enabled && actionConfig.autoFetch && !state.called && !state.loading) {
686
+ } else if (enabled && actionConfig.autoFetch && !state.called && !state.loading) {
687
+ console.log(`[Auto Fetch] for ${cacheKey}. Fetching...`);
695
688
  refetch();
696
689
  } else if (enabled && state.isStale && !state.loading) {
690
+ console.log(`[Stale State] for ${cacheKey}. Refetching...`);
697
691
  refetch();
698
692
  }
699
- }, [enabled, state.isStale, state.loading, state.called, actionConfig.autoFetch, refetch]);
693
+ prevCacheKeyRef.current = cacheKey;
694
+ }, [cacheKey, enabled, state.isStale, state.loading, state.called, actionConfig.autoFetch, refetch]);
700
695
  return state;
701
696
  }
702
697
  function useModuleContext() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-core-lib",
3
- "version": "12.0.20",
3
+ "version": "12.0.21",
4
4
  "description": "A flexible and powerful API client library for modern web applications.",
5
5
  "type": "module",
6
6