tanstack-cacher 1.3.2 → 1.3.4

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.
Files changed (3) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +7 -1
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -33,6 +33,7 @@ declare class QueryCacheManager<TData, TItem> {
33
33
  private updatePaginationOnRemove;
34
34
  add(newItem: TItem, position?: InsertPosition): void;
35
35
  update(updatedItem: Partial<TItem>, matcher?: (item: TItem) => boolean): void;
36
+ updateWithCustomLogic(updater: (oldData: any) => any): void;
36
37
  delete(itemOrId: TItem | string | number, matcher?: (item: TItem) => boolean): void;
37
38
  replace(newData: TData): void;
38
39
  clear(): void;
package/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  var reactQuery = require('@tanstack/react-query');
4
4
  var react = require('react');
5
5
 
6
- // src/index.ts
6
+ // src/hooks/useCustomMutation.ts
7
7
 
8
8
  // src/managers/QueryCacheManager/QueryCache.utils.ts
9
9
  function getAtPath(obj, path, defaultValue) {
@@ -217,6 +217,12 @@ var QueryCacheManager = class {
217
217
  this.invalidate();
218
218
  }
219
219
  }
220
+ updateWithCustomLogic(updater) {
221
+ this.config.queryClient.setQueryData(this.config.queryKey, (oldData) => {
222
+ if (!oldData) return oldData;
223
+ return updater(oldData);
224
+ });
225
+ }
220
226
  /**
221
227
  * Remove item from cache
222
228
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tanstack-cacher",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "A lightweight cache management utility for TanStack Query that simplifies adding, updating, deleting, and synchronizing cached data",
5
5
  "license": "MIT",
6
6
  "repository": {