react-native-onyx 2.0.49 → 2.0.51
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/Onyx.js +11 -1
- package/dist/OnyxUtils.js +6 -9
- package/package.json +1 -1
package/dist/Onyx.js
CHANGED
|
@@ -116,7 +116,13 @@ function connect(connectOptions) {
|
|
|
116
116
|
// We search all the keys in storage to see if any are a "match" for the subscriber we are connecting so that we
|
|
117
117
|
// can send data back to the subscriber. Note that multiple keys can match as a subscriber could either be
|
|
118
118
|
// subscribed to a "collection key" or a single key.
|
|
119
|
-
const matchingKeys =
|
|
119
|
+
const matchingKeys = [];
|
|
120
|
+
keys.forEach((key) => {
|
|
121
|
+
if (!OnyxUtils_1.default.isKeyMatch(mapping.key, key)) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
matchingKeys.push(key);
|
|
125
|
+
});
|
|
120
126
|
// If the key being connected to does not exist we initialize the value with null. For subscribers that connected
|
|
121
127
|
// directly via connect() they will simply get a null value sent to them without any information about which key matched
|
|
122
128
|
// since there are none matched. In withOnyx() we wait for all connected keys to return a value before rendering the child
|
|
@@ -576,6 +582,10 @@ function updateSnapshots(data) {
|
|
|
576
582
|
}
|
|
577
583
|
updatedData = Object.assign(Object.assign({}, updatedData), { [key]: (0, pick_1.default)(value, Object.keys(snapshotData[key])) });
|
|
578
584
|
});
|
|
585
|
+
// Skip the update if there's no data to be merged
|
|
586
|
+
if (utils_1.default.isEmptyObject(updatedData)) {
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
579
589
|
promises.push(() => merge(snapshotKey, { data: updatedData }));
|
|
580
590
|
});
|
|
581
591
|
return Promise.all(promises.map((p) => p()));
|
package/dist/OnyxUtils.js
CHANGED
|
@@ -256,16 +256,13 @@ function tryGetCachedValue(key, mapping) {
|
|
|
256
256
|
if (allCacheKeys.size === 0) {
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
// This is permissible because we're in the process of constructing the final object in a reduce function.
|
|
264
|
-
// eslint-disable-next-line no-param-reassign
|
|
265
|
-
finalObject[matchedKey] = cachedValue;
|
|
259
|
+
const values = {};
|
|
260
|
+
allCacheKeys.forEach((cacheKey) => {
|
|
261
|
+
if (!cacheKey.startsWith(key)) {
|
|
262
|
+
return;
|
|
266
263
|
}
|
|
267
|
-
|
|
268
|
-
}
|
|
264
|
+
values[cacheKey] = OnyxCache_1.default.get(cacheKey);
|
|
265
|
+
});
|
|
269
266
|
val = values;
|
|
270
267
|
}
|
|
271
268
|
if (mapping === null || mapping === void 0 ? void 0 : mapping.selector) {
|