react-native-onyx 2.0.112 → 2.0.113
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/OnyxUtils.js +14 -5
- package/package.json +1 -1
package/dist/OnyxUtils.js
CHANGED
|
@@ -1048,12 +1048,21 @@ function subscribeToKey(connectOptions) {
|
|
|
1048
1048
|
// can send data back to the subscriber. Note that multiple keys can match as a subscriber could either be
|
|
1049
1049
|
// subscribed to a "collection key" or a single key.
|
|
1050
1050
|
const matchingKeys = [];
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1051
|
+
// Performance optimization: For single key subscriptions, avoid O(n) iteration
|
|
1052
|
+
if (!isCollectionKey(mapping.key)) {
|
|
1053
|
+
if (keys.has(mapping.key)) {
|
|
1054
|
+
matchingKeys.push(mapping.key);
|
|
1054
1055
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1056
|
+
}
|
|
1057
|
+
else {
|
|
1058
|
+
// Collection case - need to iterate through all keys to find matches (O(n))
|
|
1059
|
+
keys.forEach((key) => {
|
|
1060
|
+
if (!isKeyMatch(mapping.key, key)) {
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
matchingKeys.push(key);
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1057
1066
|
// If the key being connected to does not exist we initialize the value with null. For subscribers that connected
|
|
1058
1067
|
// directly via connect() they will simply get a null value sent to them without any information about which key matched
|
|
1059
1068
|
// since there are none matched. In withOnyx() we wait for all connected keys to return a value before rendering the child
|