react-native-onyx 1.0.65 → 1.0.66

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/lib/Onyx.js CHANGED
@@ -27,8 +27,8 @@ let lastConnectionID = 0;
27
27
  // Holds a mapping of all the react components that want their state subscribed to a store key
28
28
  const callbackToStateMapping = {};
29
29
 
30
- // Stores all of the keys that Onyx can use. Must be defined in init().
31
- let onyxKeys = {};
30
+ // Keeps a copy of the values of the onyx collection keys as a map for faster lookups
31
+ let onyxCollectionKeyMap = {};
32
32
 
33
33
  // Holds a list of keys that have been directly subscribed to or recently modified from least to most recent
34
34
  let recentlyAccessedKeys = [];
@@ -141,7 +141,7 @@ function getAllKeys() {
141
141
  * @returns {Boolean}
142
142
  */
143
143
  function isCollectionKey(key) {
144
- return _.contains(_.values(onyxKeys.COLLECTION), key);
144
+ return onyxCollectionKeyMap.has(key);
145
145
  }
146
146
 
147
147
  /**
@@ -1392,8 +1392,13 @@ function init({
1392
1392
  cache.setRecentKeysLimit(maxCachedKeysCount);
1393
1393
  }
1394
1394
 
1395
- // Let Onyx know about all of our keys
1396
- onyxKeys = keys;
1395
+ // We need the value of the collection keys later for checking if a
1396
+ // key is a collection. We store it in a map for faster lookup.
1397
+ const collectionValues = _.values(keys.COLLECTION);
1398
+ onyxCollectionKeyMap = _.reduce(collectionValues, (acc, val) => {
1399
+ acc.set(val, true);
1400
+ return acc;
1401
+ }, new Map());
1397
1402
 
1398
1403
  // Set our default key states to use when initializing and clearing Onyx data
1399
1404
  defaultKeyStates = initialKeyStates;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "1.0.65",
3
+ "version": "1.0.66",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",