react-native-onyx 2.0.18 → 2.0.19
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/Onyx.js +1 -1
- package/dist/OnyxCache.d.ts +12 -0
- package/dist/OnyxCache.js +15 -1
- package/package.json +1 -1
package/dist/Onyx.js
CHANGED
|
@@ -180,7 +180,7 @@ function getAllKeys() {
|
|
|
180
180
|
}
|
|
181
181
|
// Otherwise retrieve the keys from storage and capture a promise to aid concurrent usages
|
|
182
182
|
const promise = storage_1.default.getAllKeys().then((keys) => {
|
|
183
|
-
|
|
183
|
+
OnyxCache_1.default.setAllKeys(keys);
|
|
184
184
|
return keys;
|
|
185
185
|
});
|
|
186
186
|
return OnyxCache_1.default.captureTask(taskName, promise);
|
package/dist/OnyxCache.d.ts
CHANGED
|
@@ -44,6 +44,18 @@ declare class OnyxCache {
|
|
|
44
44
|
* @param data - a map of (cache) key - values
|
|
45
45
|
*/
|
|
46
46
|
merge(data: StorageMap): void;
|
|
47
|
+
/**
|
|
48
|
+
* Allows to set all the keys at once.
|
|
49
|
+
* This is useful when we are getting
|
|
50
|
+
* all the keys from the storage provider
|
|
51
|
+
* and we want to keep the cache in sync.
|
|
52
|
+
*
|
|
53
|
+
* Previously, we had to call `addKey` in a loop
|
|
54
|
+
* to achieve the same result.
|
|
55
|
+
*
|
|
56
|
+
* @param keys - an array of keys
|
|
57
|
+
*/
|
|
58
|
+
setAllKeys(keys: Key[]): void;
|
|
47
59
|
/**
|
|
48
60
|
* Check whether the given task is already running
|
|
49
61
|
* @param taskName - unique name given for the task
|
package/dist/OnyxCache.js
CHANGED
|
@@ -19,7 +19,7 @@ class OnyxCache {
|
|
|
19
19
|
this.storageMap = {};
|
|
20
20
|
this.pendingPromises = new Map();
|
|
21
21
|
// bind all public methods to prevent problems with `this`
|
|
22
|
-
(0, bindAll_1.default)(this, 'getAllKeys', 'getValue', 'hasCacheForKey', 'addKey', 'set', 'drop', 'merge', 'hasPendingTask', 'getTaskPromise', 'captureTask', 'removeLeastRecentlyUsedKeys', 'setRecentKeysLimit');
|
|
22
|
+
(0, bindAll_1.default)(this, 'getAllKeys', 'getValue', 'hasCacheForKey', 'addKey', 'set', 'drop', 'merge', 'hasPendingTask', 'getTaskPromise', 'captureTask', 'removeLeastRecentlyUsedKeys', 'setRecentKeysLimit', 'setAllKeys');
|
|
23
23
|
}
|
|
24
24
|
/** Get all the storage keys */
|
|
25
25
|
getAllKeys() {
|
|
@@ -75,6 +75,20 @@ class OnyxCache {
|
|
|
75
75
|
this.storageKeys = new Set([...storageKeys, ...mergedKeys]);
|
|
76
76
|
mergedKeys.forEach((key) => this.addToAccessedKeys(key));
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Allows to set all the keys at once.
|
|
80
|
+
* This is useful when we are getting
|
|
81
|
+
* all the keys from the storage provider
|
|
82
|
+
* and we want to keep the cache in sync.
|
|
83
|
+
*
|
|
84
|
+
* Previously, we had to call `addKey` in a loop
|
|
85
|
+
* to achieve the same result.
|
|
86
|
+
*
|
|
87
|
+
* @param keys - an array of keys
|
|
88
|
+
*/
|
|
89
|
+
setAllKeys(keys) {
|
|
90
|
+
this.storageKeys = new Set(keys);
|
|
91
|
+
}
|
|
78
92
|
/**
|
|
79
93
|
* Check whether the given task is already running
|
|
80
94
|
* @param taskName - unique name given for the task
|