react-native-onyx 2.0.113 → 2.0.114
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/OnyxUtils.d.ts +5 -0
- package/dist/OnyxUtils.js +18 -5
- package/package.json +1 -1
package/dist/OnyxUtils.d.ts
CHANGED
|
@@ -246,6 +246,10 @@ declare function subscribeToKey<TKey extends OnyxKey>(connectOptions: ConnectOpt
|
|
|
246
246
|
*/
|
|
247
247
|
declare function unsubscribeFromKey(subscriptionID: number): void;
|
|
248
248
|
declare function updateSnapshots(data: OnyxUpdate[], mergeFn: typeof Onyx.merge): Array<() => Promise<void>>;
|
|
249
|
+
/**
|
|
250
|
+
* Clear internal variables used in this file, useful in test environments.
|
|
251
|
+
*/
|
|
252
|
+
declare function clearOnyxUtilsInternals(): void;
|
|
249
253
|
declare const OnyxUtils: {
|
|
250
254
|
METHOD: {
|
|
251
255
|
readonly SET: "set";
|
|
@@ -305,3 +309,4 @@ declare const OnyxUtils: {
|
|
|
305
309
|
};
|
|
306
310
|
export type { OnyxMethod };
|
|
307
311
|
export default OnyxUtils;
|
|
312
|
+
export { clearOnyxUtilsInternals };
|
package/dist/OnyxUtils.js
CHANGED
|
@@ -26,6 +26,7 @@ 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
|
+
exports.clearOnyxUtilsInternals = void 0;
|
|
29
30
|
/* eslint-disable no-continue */
|
|
30
31
|
const fast_equals_1 = require("fast-equals");
|
|
31
32
|
const clone_1 = __importDefault(require("lodash/clone"));
|
|
@@ -51,20 +52,20 @@ const METHOD = {
|
|
|
51
52
|
CLEAR: 'clear',
|
|
52
53
|
};
|
|
53
54
|
// Key/value store of Onyx key and arrays of values to merge
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
let mergeQueue = {};
|
|
56
|
+
let mergeQueuePromise = {};
|
|
56
57
|
// Holds a mapping of all the React components that want their state subscribed to a store key
|
|
57
|
-
|
|
58
|
+
let callbackToStateMapping = {};
|
|
58
59
|
// Keeps a copy of the values of the onyx collection keys as a map for faster lookups
|
|
59
60
|
let onyxCollectionKeySet = new Set();
|
|
60
61
|
// Holds a mapping of the connected key to the subscriptionID for faster lookups
|
|
61
|
-
|
|
62
|
+
let onyxKeyToSubscriptionIDs = new Map();
|
|
62
63
|
// Optional user-provided key value states set when Onyx initializes or clears
|
|
63
64
|
let defaultKeyStates = {};
|
|
64
65
|
let batchUpdatesPromise = null;
|
|
65
66
|
let batchUpdatesQueue = [];
|
|
66
67
|
// Used for comparison with a new update to avoid invoking the Onyx.connect callback with the same data.
|
|
67
|
-
|
|
68
|
+
let lastConnectionCallbackData = new Map();
|
|
68
69
|
let snapshotKey = null;
|
|
69
70
|
let fullyMergedSnapshotKeys;
|
|
70
71
|
// Keeps track of the last subscriptionID that was used so we can keep incrementing it
|
|
@@ -1179,6 +1180,18 @@ function updateSnapshots(data, mergeFn) {
|
|
|
1179
1180
|
});
|
|
1180
1181
|
return promises;
|
|
1181
1182
|
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Clear internal variables used in this file, useful in test environments.
|
|
1185
|
+
*/
|
|
1186
|
+
function clearOnyxUtilsInternals() {
|
|
1187
|
+
mergeQueue = {};
|
|
1188
|
+
mergeQueuePromise = {};
|
|
1189
|
+
callbackToStateMapping = {};
|
|
1190
|
+
onyxKeyToSubscriptionIDs = new Map();
|
|
1191
|
+
batchUpdatesQueue = [];
|
|
1192
|
+
lastConnectionCallbackData = new Map();
|
|
1193
|
+
}
|
|
1194
|
+
exports.clearOnyxUtilsInternals = clearOnyxUtilsInternals;
|
|
1182
1195
|
const OnyxUtils = {
|
|
1183
1196
|
METHOD,
|
|
1184
1197
|
getMergeQueue,
|