react-native-onyx 1.0.89 → 1.0.91
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 +16 -1
- 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.js +13 -1
- package/lib/storage/WebStorage.js +3 -0
- package/package.json +1 -1
package/lib/Onyx.js
CHANGED
|
@@ -802,7 +802,19 @@ function connect(mapping) {
|
|
|
802
802
|
// Commit connection only after init passes
|
|
803
803
|
deferredInitTask.promise
|
|
804
804
|
.then(() => addKeyToRecentlyAccessedIfNeeded(mapping))
|
|
805
|
-
.then(
|
|
805
|
+
.then(() => {
|
|
806
|
+
// Performance improvement
|
|
807
|
+
// If the mapping is connected to an onyx key that is not a collection
|
|
808
|
+
// we can skip the call to getAllKeys() and return an array with a single item
|
|
809
|
+
if (Boolean(mapping.key)
|
|
810
|
+
&& typeof mapping.key === 'string'
|
|
811
|
+
&& !(mapping.key.endsWith('_'))
|
|
812
|
+
&& cache.storageKeys.has(mapping.key)
|
|
813
|
+
) {
|
|
814
|
+
return [mapping.key];
|
|
815
|
+
}
|
|
816
|
+
return getAllKeys();
|
|
817
|
+
})
|
|
806
818
|
.then((keys) => {
|
|
807
819
|
// We search all the keys in storage to see if any are a "match" for the subscriber we are connecting so that we
|
|
808
820
|
// can send data back to the subscriber. Note that multiple keys can match as a subscriber could either be
|
|
@@ -40,6 +40,9 @@ const webStorage = {
|
|
|
40
40
|
this.removeItems = keys => Storage.removeItems(keys)
|
|
41
41
|
.then(() => raiseStorageSyncManyKeysEvent(keys));
|
|
42
42
|
|
|
43
|
+
this.mergeItem = (key, batchedChanges, modifiedData) => Storage.mergeItem(key, batchedChanges, modifiedData)
|
|
44
|
+
.then(() => raiseStorageSyncEvent(key));
|
|
45
|
+
|
|
43
46
|
// If we just call Storage.clear other tabs will have no idea which keys were available previously
|
|
44
47
|
// so that they can call keysChanged for them. That's why we iterate over every key and raise a storage sync
|
|
45
48
|
// event for each one
|