react-native-onyx 2.0.110 → 2.0.111

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/OnyxCache.js CHANGED
@@ -51,7 +51,7 @@ class OnyxCache {
51
51
  /** Map of keys and connection arrays whose keys will never be automatically evicted */
52
52
  this.evictionBlocklist = {};
53
53
  /** List of keys that have been directly subscribed to or recently modified from least to most recent */
54
- this.recentlyAccessedKeys = [];
54
+ this.recentlyAccessedKeys = new Set();
55
55
  this.storageKeys = new Set();
56
56
  this.nullishStorageKeys = new Set();
57
57
  this.recentKeys = new Set();
@@ -252,7 +252,7 @@ class OnyxCache {
252
252
  * Remove a key from the recently accessed key list.
253
253
  */
254
254
  removeLastAccessedKey(key) {
255
- this.recentlyAccessedKeys = this.recentlyAccessedKeys.filter((recentlyAccessedKey) => recentlyAccessedKey !== key);
255
+ this.recentlyAccessedKeys.delete(key);
256
256
  }
257
257
  /**
258
258
  * Add a key to the list of recently accessed keys. The least
@@ -265,7 +265,7 @@ class OnyxCache {
265
265
  return;
266
266
  }
267
267
  this.removeLastAccessedKey(key);
268
- this.recentlyAccessedKeys.push(key);
268
+ this.recentlyAccessedKeys.add(key);
269
269
  }
270
270
  /**
271
271
  * Take all the keys that are safe to evict and add them to
@@ -291,7 +291,12 @@ class OnyxCache {
291
291
  * Finds a key that can be safely evicted
292
292
  */
293
293
  getKeyForEviction() {
294
- return this.recentlyAccessedKeys.find((key) => !this.evictionBlocklist[key]);
294
+ for (const key of this.recentlyAccessedKeys) {
295
+ if (!this.evictionBlocklist[key]) {
296
+ return key;
297
+ }
298
+ }
299
+ return undefined;
295
300
  }
296
301
  }
297
302
  const instance = new OnyxCache();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "2.0.110",
3
+ "version": "2.0.111",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",