react-native-onyx 1.0.90 → 1.0.92
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 +27 -6
- 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/OnyxCache.js +14 -5
- package/package.json +1 -1
package/dist/web.development.js
CHANGED
|
@@ -885,7 +885,19 @@ function connect(mapping) {
|
|
|
885
885
|
// Commit connection only after init passes
|
|
886
886
|
deferredInitTask.promise.
|
|
887
887
|
then(() => addKeyToRecentlyAccessedIfNeeded(mapping)).
|
|
888
|
-
then(
|
|
888
|
+
then(() => {
|
|
889
|
+
// Performance improvement
|
|
890
|
+
// If the mapping is connected to an onyx key that is not a collection
|
|
891
|
+
// we can skip the call to getAllKeys() and return an array with a single item
|
|
892
|
+
if (Boolean(mapping.key) &&
|
|
893
|
+
typeof mapping.key === 'string' &&
|
|
894
|
+
!mapping.key.endsWith('_') &&
|
|
895
|
+
_OnyxCache__WEBPACK_IMPORTED_MODULE_4__["default"].storageKeys.has(mapping.key))
|
|
896
|
+
{
|
|
897
|
+
return [mapping.key];
|
|
898
|
+
}
|
|
899
|
+
return getAllKeys();
|
|
900
|
+
}).
|
|
889
901
|
then((keys) => {
|
|
890
902
|
// We search all the keys in storage to see if any are a "match" for the subscriber we are connecting so that we
|
|
891
903
|
// can send data back to the subscriber. Note that multiple keys can match as a subscriber could either be
|
|
@@ -1839,12 +1851,21 @@ class OnyxCache {
|
|
|
1839
1851
|
* Remove keys that don't fall into the range of recently used keys
|
|
1840
1852
|
*/
|
|
1841
1853
|
removeLeastRecentlyUsedKeys() {
|
|
1842
|
-
|
|
1843
|
-
|
|
1854
|
+
let numKeysToRemove = this.recentKeys.size - this.maxRecentKeysSize;
|
|
1855
|
+
if (numKeysToRemove <= 0) {
|
|
1856
|
+
return;
|
|
1857
|
+
}
|
|
1858
|
+
const iterator = this.recentKeys.values();
|
|
1859
|
+
const temp = [];
|
|
1860
|
+
while (numKeysToRemove > 0) {
|
|
1844
1861
|
const value = iterator.next().value;
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1862
|
+
temp.push(value);
|
|
1863
|
+
numKeysToRemove--;
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
for (let i = 0; i < temp.length; ++i) {
|
|
1867
|
+
delete this.storageMap[temp[i]];
|
|
1868
|
+
this.recentKeys.delete(temp[i]);
|
|
1848
1869
|
}
|
|
1849
1870
|
}
|
|
1850
1871
|
|