react-native-onyx 1.0.65 → 1.0.67
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/web.development.js +10 -5
- package/dist/web.development.js.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/lib/Onyx.d.ts +2 -2
- package/lib/Onyx.js +10 -5
- package/package.json +1 -1
package/lib/Onyx.d.ts
CHANGED
|
@@ -45,12 +45,12 @@ type ConnectOptions<TKey extends OnyxKey> = BaseConnectOptions &
|
|
|
45
45
|
(
|
|
46
46
|
| {
|
|
47
47
|
key: TKey extends CollectionKey ? TKey : never;
|
|
48
|
-
callback?: (value: OnyxCollection<KeyValueMapping[TKey]
|
|
48
|
+
callback?: (value: OnyxCollection<KeyValueMapping[TKey]>) => void;
|
|
49
49
|
waitForCollectionCallback: true;
|
|
50
50
|
}
|
|
51
51
|
| {
|
|
52
52
|
key: TKey;
|
|
53
|
-
callback?: (value: OnyxEntry<KeyValueMapping[TKey]>, key
|
|
53
|
+
callback?: (value: OnyxEntry<KeyValueMapping[TKey]>, key: TKey) => void;
|
|
54
54
|
waitForCollectionCallback?: false;
|
|
55
55
|
}
|
|
56
56
|
);
|
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
|
-
//
|
|
31
|
-
let
|
|
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
|
|
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
|
-
//
|
|
1396
|
-
|
|
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;
|