react-native-onyx 1.0.73 → 1.0.74

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.
@@ -177,8 +177,8 @@ let lastConnectionID = 0;
177
177
  // Holds a mapping of all the react components that want their state subscribed to a store key
178
178
  const callbackToStateMapping = {};
179
179
 
180
- // Stores all of the keys that Onyx can use. Must be defined in init().
181
- let onyxKeys = {};
180
+ // Keeps a copy of the values of the onyx collection keys as a map for faster lookups
181
+ let onyxCollectionKeyMap = new Map();
182
182
 
183
183
  // Holds a list of keys that have been directly subscribed to or recently modified from least to most recent
184
184
  let recentlyAccessedKeys = [];
@@ -296,7 +296,7 @@ function getAllKeys() {
296
296
  * @returns {Boolean}
297
297
  */
298
298
  function isCollectionKey(key) {
299
- return underscore__WEBPACK_IMPORTED_MODULE_1___default().contains(underscore__WEBPACK_IMPORTED_MODULE_1___default().values(onyxKeys.COLLECTION), key);
299
+ return onyxCollectionKeyMap.has(key);
300
300
  }
301
301
 
302
302
  /**
@@ -1577,8 +1577,13 @@ function init()
1577
1577
  _OnyxCache__WEBPACK_IMPORTED_MODULE_3__["default"].setRecentKeysLimit(maxCachedKeysCount);
1578
1578
  }
1579
1579
 
1580
- // Let Onyx know about all of our keys
1581
- onyxKeys = keys;
1580
+ // We need the value of the collection keys later for checking if a
1581
+ // key is a collection. We store it in a map for faster lookup.
1582
+ const collectionValues = underscore__WEBPACK_IMPORTED_MODULE_1___default().values(keys.COLLECTION);
1583
+ onyxCollectionKeyMap = underscore__WEBPACK_IMPORTED_MODULE_1___default().reduce(collectionValues, (acc, val) => {
1584
+ acc.set(val, true);
1585
+ return acc;
1586
+ }, new Map());
1582
1587
 
1583
1588
  // Set our default key states to use when initializing and clearing Onyx data
1584
1589
  defaultKeyStates = initialKeyStates;