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/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(getAllKeys)
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "1.0.89",
3
+ "version": "1.0.91",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",