react-native-onyx 1.0.73 → 1.0.75

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/DevTools.js CHANGED
@@ -1,6 +1,12 @@
1
- import {connectViaExtension} from 'remotedev';
2
1
  import _ from 'underscore';
3
2
 
3
+ const {connectViaExtension} = process.env.NODE_ENV === 'production' ? require('remotedev') : {
4
+ connectViaExtension: () => ({
5
+ init: () => {},
6
+ send: () => {},
7
+ }),
8
+ };
9
+
4
10
  class DevTools {
5
11
  /**
6
12
  * @callback onStateChange
@@ -42,7 +48,7 @@ class DevTools {
42
48
  */
43
49
  clearState(keysToBeRemoved = []) {
44
50
  const pairs = _.map(keysToBeRemoved, key => [key, undefined]);
45
- this.registerAction('CLEAR', undefined, _.object((pairs)));
51
+ this.registerAction('CLEAR', undefined, _.object(pairs));
46
52
  }
47
53
  }
48
54
 
package/lib/Onyx.js CHANGED
@@ -28,8 +28,8 @@ let lastConnectionID = 0;
28
28
  // Holds a mapping of all the react components that want their state subscribed to a store key
29
29
  const callbackToStateMapping = {};
30
30
 
31
- // Stores all of the keys that Onyx can use. Must be defined in init().
32
- let onyxKeys = {};
31
+ // Keeps a copy of the values of the onyx collection keys as a map for faster lookups
32
+ let onyxCollectionKeyMap = new Map();
33
33
 
34
34
  // Holds a list of keys that have been directly subscribed to or recently modified from least to most recent
35
35
  let recentlyAccessedKeys = [];
@@ -147,7 +147,7 @@ function getAllKeys() {
147
147
  * @returns {Boolean}
148
148
  */
149
149
  function isCollectionKey(key) {
150
- return _.contains(_.values(onyxKeys.COLLECTION), key);
150
+ return onyxCollectionKeyMap.has(key);
151
151
  }
152
152
 
153
153
  /**
@@ -1428,8 +1428,13 @@ function init({
1428
1428
  cache.setRecentKeysLimit(maxCachedKeysCount);
1429
1429
  }
1430
1430
 
1431
- // Let Onyx know about all of our keys
1432
- onyxKeys = keys;
1431
+ // We need the value of the collection keys later for checking if a
1432
+ // key is a collection. We store it in a map for faster lookup.
1433
+ const collectionValues = _.values(keys.COLLECTION);
1434
+ onyxCollectionKeyMap = _.reduce(collectionValues, (acc, val) => {
1435
+ acc.set(val, true);
1436
+ return acc;
1437
+ }, new Map());
1433
1438
 
1434
1439
  // Set our default key states to use when initializing and clearing Onyx data
1435
1440
  defaultKeyStates = initialKeyStates;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "1.0.73",
3
+ "version": "1.0.75",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",