@umituz/react-native-subscription 2.14.35 → 2.14.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-subscription",
3
- "version": "2.14.35",
3
+ "version": "2.14.36",
4
4
  "description": "Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -33,6 +33,7 @@
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@tanstack/react-query": ">=5.0.0",
36
+ "@umituz/react-native-tanstack": "latest",
36
37
  "@umituz/react-native-design-system": "latest",
37
38
  "@umituz/react-native-firebase": "latest",
38
39
  "@umituz/react-native-legal": "latest",
@@ -49,6 +50,7 @@
49
50
  },
50
51
  "devDependencies": {
51
52
  "@tanstack/react-query": "^5.0.0",
53
+ "@umituz/react-native-tanstack": "*",
52
54
  "@types/react": "~19.1.10",
53
55
  "@typescript-eslint/eslint-plugin": "^8.50.1",
54
56
  "@typescript-eslint/parser": "^8.50.1",
package/src/index.ts CHANGED
@@ -383,6 +383,11 @@ export {
383
383
  type CreditAllocation,
384
384
  } from "./utils/creditMapper";
385
385
 
386
+ export {
387
+ invalidateCreditsCache,
388
+ invalidateAllCreditsCache,
389
+ } from "./utils/cacheInvalidation";
390
+
386
391
  // =============================================================================
387
392
  // REVENUECAT - Errors
388
393
  // =============================================================================
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Cache Invalidation Utilities
3
+ * Centralized cache invalidation for credits and subscription queries
4
+ */
5
+
6
+ import {
7
+ getGlobalQueryClient,
8
+ hasGlobalQueryClient,
9
+ } from "@umituz/react-native-tanstack";
10
+ import { creditsQueryKeys } from "../presentation/hooks/useCredits";
11
+
12
+ declare const __DEV__: boolean;
13
+
14
+ /**
15
+ * Invalidate credits cache for a user.
16
+ * Call this after credits are deducted to ensure UI updates immediately.
17
+ */
18
+ export const invalidateCreditsCache = (userId: string): void => {
19
+ if (!hasGlobalQueryClient()) {
20
+ if (__DEV__) {
21
+ console.warn(
22
+ "[Subscription] QueryClient not available for cache invalidation",
23
+ );
24
+ }
25
+ return;
26
+ }
27
+
28
+ const queryClient = getGlobalQueryClient();
29
+ queryClient.invalidateQueries({
30
+ queryKey: creditsQueryKeys.user(userId),
31
+ });
32
+ };
33
+
34
+ /**
35
+ * Invalidate all credits cache (for all users).
36
+ * Useful when user logs out or switches accounts.
37
+ */
38
+ export const invalidateAllCreditsCache = (): void => {
39
+ if (!hasGlobalQueryClient()) return;
40
+
41
+ const queryClient = getGlobalQueryClient();
42
+ queryClient.invalidateQueries({
43
+ queryKey: creditsQueryKeys.all,
44
+ });
45
+ };