forked from apollographql/apollo-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add getKey and forgetKey API's to optimism
- Loading branch information
Sofian Hnaide
committed
Apr 21, 2021
1 parent
be42d88
commit 9e20661
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
diff --git a/node_modules/optimism/lib/bundle.cjs.js b/node_modules/optimism/lib/bundle.cjs.js | ||
index 26e4f9e..eaf15bf 100644 | ||
--- a/node_modules/optimism/lib/bundle.cjs.js | ||
+++ b/node_modules/optimism/lib/bundle.cjs.js | ||
@@ -458,6 +458,12 @@ function wrap(originalFunction, options) { | ||
var key = makeCacheKey.apply(null, arguments); | ||
return key !== void 0 && cache.delete(key); | ||
}; | ||
+ optimistic.getKey = function () { | ||
+ return makeCacheKey.apply(null, keyArgs ? keyArgs.apply(null, arguments) : arguments); | ||
+ }; | ||
+ optimistic.forgetKey = function (key) { | ||
+ return key !== void 0 && cache.delete(key); | ||
+ }; | ||
return optimistic; | ||
} | ||
|
||
diff --git a/node_modules/optimism/lib/bundle.esm.js b/node_modules/optimism/lib/bundle.esm.js | ||
index 02bc3e5..05e30fc 100644 | ||
--- a/node_modules/optimism/lib/bundle.esm.js | ||
+++ b/node_modules/optimism/lib/bundle.esm.js | ||
@@ -456,6 +456,12 @@ function wrap(originalFunction, options) { | ||
var key = makeCacheKey.apply(null, arguments); | ||
return key !== void 0 && cache.delete(key); | ||
}; | ||
+ optimistic.getKey = function () { | ||
+ return makeCacheKey.apply(null, keyArgs ? keyArgs.apply(null, arguments) : arguments); | ||
+ }; | ||
+ optimistic.forgetKey = function (key) { | ||
+ return key !== void 0 && cache.delete(key); | ||
+ }; | ||
return optimistic; | ||
} | ||
|
||
diff --git a/node_modules/optimism/lib/index.d.ts b/node_modules/optimism/lib/index.d.ts | ||
index e945216..5676430 100644 | ||
--- a/node_modules/optimism/lib/index.d.ts | ||
+++ b/node_modules/optimism/lib/index.d.ts | ||
@@ -8,6 +8,8 @@ export declare type OptimisticWrapperFunction<TArgs extends any[], TResult, TKey | ||
dirty: (...args: TKeyArgs) => void; | ||
peek: (...args: TKeyArgs) => TResult | undefined; | ||
forget: (...args: TKeyArgs) => boolean; | ||
+ getKey: (...args: TArgs) => any; | ||
+ forgetKey: (key: any) => boolean; | ||
}; | ||
export declare type OptimisticWrapOptions<TArgs extends any[], TKeyArgs extends any[] = TArgs> = { | ||
max?: number; |