react-native-onyx 2.0.101 → 2.0.102
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 +1 -1
- package/dist/OnyxCache.js +3 -4
- package/dist/OnyxUtils.js +7 -10
- package/dist/utils.js +2 -4
- package/package.json +2 -2
package/dist/Onyx.js
CHANGED
|
@@ -40,7 +40,7 @@ const OnyxConnectionManager_1 = __importDefault(require("./OnyxConnectionManager
|
|
|
40
40
|
const GlobalSettings = __importStar(require("./GlobalSettings"));
|
|
41
41
|
const metrics_1 = __importDefault(require("./metrics"));
|
|
42
42
|
/** Initialize the store with actions and listening for storage events */
|
|
43
|
-
function init({ keys = {}, initialKeyStates = {}, safeEvictionKeys = [], maxCachedKeysCount = 1000, shouldSyncMultipleInstances =
|
|
43
|
+
function init({ keys = {}, initialKeyStates = {}, safeEvictionKeys = [], maxCachedKeysCount = 1000, shouldSyncMultipleInstances = !!global.localStorage, debugSetState = false, enablePerformanceMetrics = false, skippableCollectionMemberIDs = [], }) {
|
|
44
44
|
var _a;
|
|
45
45
|
if (enablePerformanceMetrics) {
|
|
46
46
|
GlobalSettings.setPerformanceMetricsEnabled(true);
|
package/dist/OnyxCache.js
CHANGED
|
@@ -169,10 +169,9 @@ class OnyxCache {
|
|
|
169
169
|
temp.push(value);
|
|
170
170
|
numKeysToRemove--;
|
|
171
171
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
this.recentKeys.delete(temp[i]);
|
|
172
|
+
for (const key of temp) {
|
|
173
|
+
delete this.storageMap[key];
|
|
174
|
+
this.recentKeys.delete(key);
|
|
176
175
|
}
|
|
177
176
|
}
|
|
178
177
|
/** Set the recent keys list size */
|
package/dist/OnyxUtils.js
CHANGED
|
@@ -26,7 +26,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
/* eslint-disable @typescript-eslint/prefer-for-of */
|
|
30
29
|
/* eslint-disable no-continue */
|
|
31
30
|
const fast_equals_1 = require("fast-equals");
|
|
32
31
|
const clone_1 = __importDefault(require("lodash/clone"));
|
|
@@ -537,8 +536,8 @@ function keysChanged(collectionKey, partialCollection, partialPreviousCollection
|
|
|
537
536
|
// and does not represent all of the combined keys and values for a collection key. It is just the "new" data that was merged in via mergeCollection().
|
|
538
537
|
const stateMappingKeys = Object.keys(callbackToStateMapping);
|
|
539
538
|
const collectionKeyLength = collectionKey.length;
|
|
540
|
-
for (
|
|
541
|
-
const subscriber = callbackToStateMapping[
|
|
539
|
+
for (const stateMappingKey of stateMappingKeys) {
|
|
540
|
+
const subscriber = callbackToStateMapping[stateMappingKey];
|
|
542
541
|
if (!subscriber) {
|
|
543
542
|
continue;
|
|
544
543
|
}
|
|
@@ -569,8 +568,7 @@ function keysChanged(collectionKey, partialCollection, partialPreviousCollection
|
|
|
569
568
|
// If they are not using waitForCollectionCallback then we notify the subscriber with
|
|
570
569
|
// the new merged data but only for any keys in the partial collection.
|
|
571
570
|
const dataKeys = Object.keys(partialCollection !== null && partialCollection !== void 0 ? partialCollection : {});
|
|
572
|
-
for (
|
|
573
|
-
const dataKey = dataKeys[j];
|
|
571
|
+
for (const dataKey of dataKeys) {
|
|
574
572
|
if ((0, fast_equals_1.deepEqual)(cachedCollection[dataKey], previousCollection[dataKey])) {
|
|
575
573
|
continue;
|
|
576
574
|
}
|
|
@@ -619,8 +617,7 @@ function keysChanged(collectionKey, partialCollection, partialPreviousCollection
|
|
|
619
617
|
const prevCollection = (_a = prevState === null || prevState === void 0 ? void 0 : prevState[subscriber.statePropertyName]) !== null && _a !== void 0 ? _a : {};
|
|
620
618
|
const finalCollection = (0, clone_1.default)(prevCollection);
|
|
621
619
|
const dataKeys = Object.keys(partialCollection !== null && partialCollection !== void 0 ? partialCollection : {});
|
|
622
|
-
for (
|
|
623
|
-
const dataKey = dataKeys[j];
|
|
620
|
+
for (const dataKey of dataKeys) {
|
|
624
621
|
finalCollection[dataKey] = cachedCollection[dataKey];
|
|
625
622
|
}
|
|
626
623
|
if ((0, fast_equals_1.deepEqual)(prevCollection, finalCollection)) {
|
|
@@ -719,8 +716,8 @@ function keyChanged(key, value, previousValue, canUpdateSubscriber = () => true,
|
|
|
719
716
|
}
|
|
720
717
|
}
|
|
721
718
|
const cachedCollections = {};
|
|
722
|
-
for (
|
|
723
|
-
const subscriber = callbackToStateMapping[
|
|
719
|
+
for (const stateMappingKey of stateMappingKeys) {
|
|
720
|
+
const subscriber = callbackToStateMapping[stateMappingKey];
|
|
724
721
|
if (!subscriber || !isKeyMatch(subscriber.key, key) || !canUpdateSubscriber(subscriber)) {
|
|
725
722
|
continue;
|
|
726
723
|
}
|
|
@@ -1093,7 +1090,7 @@ function subscribeToKey(connectOptions) {
|
|
|
1093
1090
|
// Performance improvement
|
|
1094
1091
|
// If the mapping is connected to an onyx key that is not a collection
|
|
1095
1092
|
// we can skip the call to getAllKeys() and return an array with a single item
|
|
1096
|
-
if (
|
|
1093
|
+
if (!!mapping.key && typeof mapping.key === 'string' && !isCollectionKey(mapping.key) && OnyxCache_1.default.getAllKeys().has(mapping.key)) {
|
|
1097
1094
|
return new Set([mapping.key]);
|
|
1098
1095
|
}
|
|
1099
1096
|
return getAllKeys();
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable @typescript-eslint/prefer-for-of */
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
/** Checks whether the given object is an object and not null/undefined. */
|
|
5
4
|
function isEmptyObject(obj) {
|
|
@@ -132,8 +131,7 @@ function checkCompatibilityWithExistingValue(value, existingValue) {
|
|
|
132
131
|
function filterObject(obj, condition, include) {
|
|
133
132
|
const result = {};
|
|
134
133
|
const entries = Object.entries(obj);
|
|
135
|
-
for (
|
|
136
|
-
const [key, value] = entries[i];
|
|
134
|
+
for (const [key, value] of entries) {
|
|
137
135
|
let shouldInclude;
|
|
138
136
|
if (Array.isArray(condition)) {
|
|
139
137
|
shouldInclude = condition.includes(key);
|
|
@@ -142,7 +140,7 @@ function filterObject(obj, condition, include) {
|
|
|
142
140
|
shouldInclude = key === condition;
|
|
143
141
|
}
|
|
144
142
|
else {
|
|
145
|
-
shouldInclude = condition(
|
|
143
|
+
shouldInclude = condition([key, value]);
|
|
146
144
|
}
|
|
147
145
|
if (include ? shouldInclude : !shouldInclude) {
|
|
148
146
|
result[key] = value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-onyx",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.102",
|
|
4
4
|
"author": "Expensify, Inc.",
|
|
5
5
|
"homepage": "https://expensify.com",
|
|
6
6
|
"description": "State management for React Native",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@vercel/ncc": "0.38.1",
|
|
72
72
|
"date-fns": "^4.1.0",
|
|
73
73
|
"eslint": "^8.56.0",
|
|
74
|
-
"eslint-config-expensify": "^2.0.
|
|
74
|
+
"eslint-config-expensify": "^2.0.81",
|
|
75
75
|
"eslint-config-prettier": "^8.8.0",
|
|
76
76
|
"eslint-plugin-import": "^2.29.1",
|
|
77
77
|
"eslint-plugin-jsx-a11y": "^6.8.0",
|