api-core-lib 12.0.19 → 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,13 +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 prevCacheKeyRef = (0, import_react4.useRef)(cacheKey);
720
721
  (0, import_react4.useEffect)(() => {
721
- if (enabled && actionConfig.autoFetch && !state.called && !state.loading) {
722
+ if (prevCacheKeyRef.current !== cacheKey && enabled && state.called) {
723
+ console.log(`[Cache Key Changed] from ${prevCacheKeyRef.current} to ${cacheKey}. Refetching...`);
724
+ refetch();
725
+ } else if (enabled && actionConfig.autoFetch && !state.called && !state.loading) {
726
+ console.log(`[Auto Fetch] for ${cacheKey}. Fetching...`);
722
727
  refetch();
723
728
  } else if (enabled && state.isStale && !state.loading) {
729
+ console.log(`[Stale State] for ${cacheKey}. Refetching...`);
724
730
  refetch();
725
731
  }
726
- }, [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]);
727
734
  return state;
728
735
  }
729
736
  function useModuleContext() {
@@ -774,7 +781,7 @@ function useApiModule(axiosInstance, moduleConfig, options = {}) {
774
781
  body: input,
775
782
  config: options2.config
776
783
  });
777
- console.log("[API Result]", result);
784
+ console.log("[API Result execute]", result);
778
785
  if (shouldCache) {
779
786
  globalStateManager.setState(cacheKey, (prev) => ({
780
787
  ...prev,
package/dist/client.js CHANGED
@@ -678,13 +678,20 @@ function useApiActionState(actionConfig, cacheKey, execute, input, enabled) {
678
678
  const refetch = useCallback3(() => {
679
679
  execute(inputRef.current);
680
680
  }, [execute]);
681
+ const prevCacheKeyRef = useRef4(cacheKey);
681
682
  useEffect4(() => {
682
- if (enabled && actionConfig.autoFetch && !state.called && !state.loading) {
683
+ if (prevCacheKeyRef.current !== cacheKey && enabled && state.called) {
684
+ console.log(`[Cache Key Changed] from ${prevCacheKeyRef.current} to ${cacheKey}. Refetching...`);
685
+ refetch();
686
+ } else if (enabled && actionConfig.autoFetch && !state.called && !state.loading) {
687
+ console.log(`[Auto Fetch] for ${cacheKey}. Fetching...`);
683
688
  refetch();
684
689
  } else if (enabled && state.isStale && !state.loading) {
690
+ console.log(`[Stale State] for ${cacheKey}. Refetching...`);
685
691
  refetch();
686
692
  }
687
- }, [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]);
688
695
  return state;
689
696
  }
690
697
  function useModuleContext() {
@@ -735,7 +742,7 @@ function useApiModule(axiosInstance, moduleConfig, options = {}) {
735
742
  body: input,
736
743
  config: options2.config
737
744
  });
738
- console.log("[API Result]", result);
745
+ console.log("[API Result execute]", result);
739
746
  if (shouldCache) {
740
747
  globalStateManager.setState(cacheKey, (prev) => ({
741
748
  ...prev,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-core-lib",
3
- "version": "12.0.19",
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