react-native-onyx 1.0.77 → 1.0.79
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 +146 -44
- 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 +107 -36
- package/lib/batch.js +3 -0
- package/lib/batch.native.js +3 -0
- package/lib/storage/providers/SQLiteStorage.js +4 -1
- package/package.json +3 -1
package/dist/web.development.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
2
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory(require("fast-equals"), require("underscore"), require("idb-keyval"), require("lodash/transform"), require("react"));
|
|
3
|
+
module.exports = factory(require("fast-equals"), require("underscore"), require("idb-keyval"), require("lodash/transform"), require("react-dom"), require("react"));
|
|
4
4
|
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define(["fast-equals", "underscore", "idb-keyval", "lodash/transform", "react"], factory);
|
|
5
|
+
define(["fast-equals", "underscore", "idb-keyval", "lodash/transform", "react-dom", "react"], factory);
|
|
6
6
|
else if(typeof exports === 'object')
|
|
7
|
-
exports["react-native-onyx/web"] = factory(require("fast-equals"), require("underscore"), require("idb-keyval"), require("lodash/transform"), require("react"));
|
|
7
|
+
exports["react-native-onyx/web"] = factory(require("fast-equals"), require("underscore"), require("idb-keyval"), require("lodash/transform"), require("react-dom"), require("react"));
|
|
8
8
|
else
|
|
9
|
-
root["react-native-onyx/web"] = factory(root["fast-equals"], root["underscore"], root["idb-keyval"], root["lodash/transform"], root["react"]);
|
|
10
|
-
})(self, (__WEBPACK_EXTERNAL_MODULE_fast_equals__, __WEBPACK_EXTERNAL_MODULE_underscore__, __WEBPACK_EXTERNAL_MODULE_idb_keyval__, __WEBPACK_EXTERNAL_MODULE_lodash_transform__, __WEBPACK_EXTERNAL_MODULE_react__) => {
|
|
9
|
+
root["react-native-onyx/web"] = factory(root["fast-equals"], root["underscore"], root["idb-keyval"], root["lodash/transform"], root["react-dom"], root["react"]);
|
|
10
|
+
})(self, (__WEBPACK_EXTERNAL_MODULE_fast_equals__, __WEBPACK_EXTERNAL_MODULE_underscore__, __WEBPACK_EXTERNAL_MODULE_idb_keyval__, __WEBPACK_EXTERNAL_MODULE_lodash_transform__, __WEBPACK_EXTERNAL_MODULE_react_dom__, __WEBPACK_EXTERNAL_MODULE_react__) => {
|
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
|
12
12
|
/******/ var __webpack_modules__ = ({
|
|
13
13
|
|
|
@@ -77,9 +77,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
77
77
|
/* harmony import */ var _OnyxCache__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./OnyxCache */ "./lib/OnyxCache.js");
|
|
78
78
|
/* harmony import */ var _Str__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Str */ "./lib/Str.js");
|
|
79
79
|
/* harmony import */ var _createDeferredTask__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./createDeferredTask */ "./lib/createDeferredTask.js");
|
|
80
|
-
/* harmony import */ var
|
|
80
|
+
/* harmony import */ var _fastMerge__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./fastMerge */ "./lib/fastMerge.js");
|
|
81
81
|
/* harmony import */ var _metrics_PerformanceUtils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./metrics/PerformanceUtils */ "./lib/metrics/PerformanceUtils.js");
|
|
82
82
|
/* harmony import */ var _storage__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./storage */ "./lib/storage/index.web.js");
|
|
83
|
+
/* harmony import */ var _batch__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./batch */ "./lib/batch.js");
|
|
83
84
|
/* eslint-disable no-continue */
|
|
84
85
|
|
|
85
86
|
|
|
@@ -91,6 +92,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
91
92
|
|
|
92
93
|
|
|
93
94
|
|
|
95
|
+
|
|
94
96
|
// Method constants
|
|
95
97
|
const METHOD = {
|
|
96
98
|
SET: 'set',
|
|
@@ -102,6 +104,7 @@ const METHOD = {
|
|
|
102
104
|
|
|
103
105
|
// Key/value store of Onyx key and arrays of values to merge
|
|
104
106
|
const mergeQueue = {};
|
|
107
|
+
const mergeQueuePromise = {};
|
|
105
108
|
|
|
106
109
|
// Keeps track of the last connectionID that was used so we can keep incrementing it
|
|
107
110
|
let lastConnectionID = 0;
|
|
@@ -415,8 +418,10 @@ function getCachedCollection(collectionKey) {
|
|
|
415
418
|
* @private
|
|
416
419
|
* @param {String} collectionKey
|
|
417
420
|
* @param {Object} partialCollection - a partial collection of grouped member keys
|
|
421
|
+
* @param {boolean} [notifyRegularSubscibers=true]
|
|
422
|
+
* @param {boolean} [notifyWithOnyxSubscibers=true]
|
|
418
423
|
*/
|
|
419
|
-
function keysChanged(collectionKey, partialCollection) {
|
|
424
|
+
function keysChanged(collectionKey, partialCollection) {let notifyRegularSubscibers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;let notifyWithOnyxSubscibers = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
420
425
|
// We are iterating over all subscribers similar to keyChanged(). However, we are looking for subscribers who are subscribing to either a collection key or
|
|
421
426
|
// individual collection key member for the collection that is being updated. It is important to note that the collection parameter cane be a PARTIAL collection
|
|
422
427
|
// 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().
|
|
@@ -448,6 +453,10 @@ function keysChanged(collectionKey, partialCollection) {
|
|
|
448
453
|
|
|
449
454
|
// Regular Onyx.connect() subscriber found.
|
|
450
455
|
if (underscore__WEBPACK_IMPORTED_MODULE_1___default().isFunction(subscriber.callback)) {
|
|
456
|
+
if (!notifyRegularSubscibers) {
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
|
|
451
460
|
// If they are subscribed to the collection key and using waitForCollectionCallback then we'll
|
|
452
461
|
// send the whole cached collection.
|
|
453
462
|
if (isSubscribedToCollectionKey) {
|
|
@@ -478,6 +487,10 @@ function keysChanged(collectionKey, partialCollection) {
|
|
|
478
487
|
|
|
479
488
|
// React component subscriber found.
|
|
480
489
|
if (subscriber.withOnyxInstance) {
|
|
490
|
+
if (!notifyWithOnyxSubscibers) {
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
|
|
481
494
|
// We are subscribed to a collection key so we must update the data in state with the new
|
|
482
495
|
// collection member key values from the partial update.
|
|
483
496
|
if (isSubscribedToCollectionKey) {
|
|
@@ -569,8 +582,10 @@ function keysChanged(collectionKey, partialCollection) {
|
|
|
569
582
|
* @param {String} key
|
|
570
583
|
* @param {*} data
|
|
571
584
|
* @param {Function} [canUpdateSubscriber] only subscribers that pass this truth test will be updated
|
|
585
|
+
* @param {boolean} [notifyRegularSubscibers=true]
|
|
586
|
+
* @param {boolean} [notifyWithOnyxSubscibers=true]
|
|
572
587
|
*/
|
|
573
|
-
function keyChanged(key, data, canUpdateSubscriber) {
|
|
588
|
+
function keyChanged(key, data, canUpdateSubscriber) {let notifyRegularSubscibers = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;let notifyWithOnyxSubscibers = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
574
589
|
// Add or remove this key from the recentlyAccessedKeys lists
|
|
575
590
|
if (!underscore__WEBPACK_IMPORTED_MODULE_1___default().isNull(data)) {
|
|
576
591
|
addLastAccessedKey(key);
|
|
@@ -590,6 +605,9 @@ function keyChanged(key, data, canUpdateSubscriber) {
|
|
|
590
605
|
|
|
591
606
|
// Subscriber is a regular call to connect() and provided a callback
|
|
592
607
|
if (underscore__WEBPACK_IMPORTED_MODULE_1___default().isFunction(subscriber.callback)) {
|
|
608
|
+
if (!notifyRegularSubscibers) {
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
593
611
|
if (isCollectionKey(subscriber.key) && subscriber.waitForCollectionCallback) {
|
|
594
612
|
const cachedCollection = getCachedCollection(subscriber.key);
|
|
595
613
|
cachedCollection[key] = data;
|
|
@@ -603,6 +621,10 @@ function keyChanged(key, data, canUpdateSubscriber) {
|
|
|
603
621
|
|
|
604
622
|
// Subscriber connected via withOnyx() HOC
|
|
605
623
|
if (subscriber.withOnyxInstance) {
|
|
624
|
+
if (!notifyWithOnyxSubscibers) {
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
627
|
+
|
|
606
628
|
// Check if we are subscribing to a collection key and overwrite the collection member key value in state
|
|
607
629
|
if (isCollectionKey(subscriber.key)) {
|
|
608
630
|
// If the subscriber has a selector, then the consumer of this data must only be given the data
|
|
@@ -883,22 +905,62 @@ function disconnect(connectionID, keyToRemoveFromEvictionBlocklist) {
|
|
|
883
905
|
delete callbackToStateMapping[connectionID];
|
|
884
906
|
}
|
|
885
907
|
|
|
908
|
+
let batchUpdatesPromise = null;
|
|
909
|
+
let batchUpdatesQueue = [];
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* We are batching together onyx updates. This helps with use cases where we schedule onyx updates after each other.
|
|
913
|
+
* This happens for example in the Onyx.update function, where we process API responses that might contain a lot of
|
|
914
|
+
* update operations. Instead of calling the subscribers for each update operation, we batch them together which will
|
|
915
|
+
* cause react to schedule the updates at once instead of after each other. This is mainly a performance optimization.
|
|
916
|
+
* @returns {Promise}
|
|
917
|
+
*/
|
|
918
|
+
function maybeFlushBatchUpdates() {
|
|
919
|
+
if (batchUpdatesPromise) {
|
|
920
|
+
return batchUpdatesPromise;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
batchUpdatesPromise = new Promise((resolve) => {
|
|
924
|
+
/* We use (setTimeout, 0) here which should be called once native module calls are flushed (usually at the end of the frame)
|
|
925
|
+
* We may investigate if (setTimeout, 1) (which in React Native is equal to requestAnimationFrame) works even better
|
|
926
|
+
* then the batch will be flushed on next frame.
|
|
927
|
+
*/
|
|
928
|
+
setTimeout(() => {
|
|
929
|
+
const updatesCopy = batchUpdatesQueue;
|
|
930
|
+
batchUpdatesQueue = [];
|
|
931
|
+
batchUpdatesPromise = null;
|
|
932
|
+
(0,_batch__WEBPACK_IMPORTED_MODULE_8__["default"])(() => {
|
|
933
|
+
updatesCopy.forEach((applyUpdates) => {
|
|
934
|
+
applyUpdates();
|
|
935
|
+
});
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
resolve();
|
|
939
|
+
}, 0);
|
|
940
|
+
});
|
|
941
|
+
return batchUpdatesPromise;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
function batchUpdates(updates) {
|
|
945
|
+
batchUpdatesQueue.push(updates);
|
|
946
|
+
return maybeFlushBatchUpdates();
|
|
947
|
+
}
|
|
948
|
+
|
|
886
949
|
/**
|
|
887
|
-
*
|
|
888
|
-
* For this reason, Onyx works more similar to what you might expect from a native AsyncStorage with reads, writes, etc all becoming
|
|
889
|
-
* available async. Since we have code in our main applications that might expect things to work this way it's not safe to change this
|
|
890
|
-
* behavior just yet.
|
|
950
|
+
* Schedules an update that will be appended to the macro task queue (so it doesn't update the subscribers immediately).
|
|
891
951
|
*
|
|
892
952
|
* @example
|
|
893
|
-
*
|
|
953
|
+
* scheduleSubscriberUpdate(key, value, subscriber => subscriber.initWithStoredValues === false)
|
|
894
954
|
*
|
|
895
955
|
* @param {String} key
|
|
896
956
|
* @param {*} value
|
|
897
957
|
* @param {Function} [canUpdateSubscriber] only subscribers that pass this truth test will be updated
|
|
958
|
+
* @returns {Promise}
|
|
898
959
|
*/
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
960
|
+
function scheduleSubscriberUpdate(key, value, canUpdateSubscriber) {
|
|
961
|
+
const promise = Promise.resolve().then(() => keyChanged(key, value, canUpdateSubscriber, true, false));
|
|
962
|
+
batchUpdates(() => keyChanged(key, value, canUpdateSubscriber, false, true));
|
|
963
|
+
return Promise.all([maybeFlushBatchUpdates(), promise]);
|
|
902
964
|
}
|
|
903
965
|
|
|
904
966
|
/**
|
|
@@ -908,10 +970,12 @@ function notifySubscribersOnNextTick(key, value, canUpdateSubscriber) {
|
|
|
908
970
|
*
|
|
909
971
|
* @param {String} key
|
|
910
972
|
* @param {*} value
|
|
973
|
+
* @returns {Promise}
|
|
911
974
|
*/
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
975
|
+
function scheduleNotifyCollectionSubscribers(key, value) {
|
|
976
|
+
const promise = Promise.resolve().then(() => keysChanged(key, value, true, false));
|
|
977
|
+
batchUpdates(() => keysChanged(key, value, false, true));
|
|
978
|
+
return Promise.all([maybeFlushBatchUpdates(), promise]);
|
|
915
979
|
}
|
|
916
980
|
|
|
917
981
|
/**
|
|
@@ -923,7 +987,7 @@ function notifyCollectionSubscribersOnNextTick(key, value) {
|
|
|
923
987
|
*/
|
|
924
988
|
function remove(key) {
|
|
925
989
|
_OnyxCache__WEBPACK_IMPORTED_MODULE_3__["default"].drop(key);
|
|
926
|
-
|
|
990
|
+
scheduleSubscriberUpdate(key, null);
|
|
927
991
|
return _storage__WEBPACK_IMPORTED_MODULE_4__["default"].removeItem(key);
|
|
928
992
|
}
|
|
929
993
|
|
|
@@ -984,6 +1048,7 @@ function evictStorageAndRetry(error, onyxMethod) {for (var _len = arguments.leng
|
|
|
984
1048
|
* @param {*} value
|
|
985
1049
|
* @param {Boolean} hasChanged
|
|
986
1050
|
* @param {String} method
|
|
1051
|
+
* @returns {Promise}
|
|
987
1052
|
*/
|
|
988
1053
|
function broadcastUpdate(key, value, hasChanged, method) {
|
|
989
1054
|
// Logging properties only since values could be sensitive things we don't want to log
|
|
@@ -997,7 +1062,7 @@ function broadcastUpdate(key, value, hasChanged, method) {
|
|
|
997
1062
|
_OnyxCache__WEBPACK_IMPORTED_MODULE_3__["default"].addToAccessedKeys(key);
|
|
998
1063
|
}
|
|
999
1064
|
|
|
1000
|
-
|
|
1065
|
+
return scheduleSubscriberUpdate(key, value, (subscriber) => hasChanged || subscriber.initWithStoredValues === false);
|
|
1001
1066
|
}
|
|
1002
1067
|
|
|
1003
1068
|
/**
|
|
@@ -1048,15 +1113,16 @@ function set(key, value) {
|
|
|
1048
1113
|
const hasChanged = _OnyxCache__WEBPACK_IMPORTED_MODULE_3__["default"].hasValueChanged(key, valueWithNullRemoved);
|
|
1049
1114
|
|
|
1050
1115
|
// This approach prioritizes fast UI changes without waiting for data to be stored in device storage.
|
|
1051
|
-
broadcastUpdate(key, valueWithNullRemoved, hasChanged, 'set');
|
|
1116
|
+
const updatePromise = broadcastUpdate(key, valueWithNullRemoved, hasChanged, 'set');
|
|
1052
1117
|
|
|
1053
1118
|
// If the value has not changed, calling Storage.setItem() would be redundant and a waste of performance, so return early instead.
|
|
1054
1119
|
if (!hasChanged) {
|
|
1055
|
-
return
|
|
1120
|
+
return updatePromise;
|
|
1056
1121
|
}
|
|
1057
1122
|
|
|
1058
1123
|
return _storage__WEBPACK_IMPORTED_MODULE_4__["default"].setItem(key, valueWithNullRemoved).
|
|
1059
|
-
catch((error) => evictStorageAndRetry(error, set, key, valueWithNullRemoved))
|
|
1124
|
+
catch((error) => evictStorageAndRetry(error, set, key, valueWithNullRemoved)).
|
|
1125
|
+
then(() => updatePromise);
|
|
1060
1126
|
}
|
|
1061
1127
|
|
|
1062
1128
|
/**
|
|
@@ -1082,14 +1148,15 @@ function prepareKeyValuePairsForStorage(data) {
|
|
|
1082
1148
|
function multiSet(data) {
|
|
1083
1149
|
const keyValuePairs = prepareKeyValuePairsForStorage(data);
|
|
1084
1150
|
|
|
1085
|
-
underscore__WEBPACK_IMPORTED_MODULE_1___default().
|
|
1151
|
+
const updatePromises = underscore__WEBPACK_IMPORTED_MODULE_1___default().map(data, (val, key) => {
|
|
1086
1152
|
// Update cache and optimistically inform subscribers on the next tick
|
|
1087
1153
|
_OnyxCache__WEBPACK_IMPORTED_MODULE_3__["default"].set(key, val);
|
|
1088
|
-
|
|
1154
|
+
return scheduleSubscriberUpdate(key, val);
|
|
1089
1155
|
});
|
|
1090
1156
|
|
|
1091
1157
|
return _storage__WEBPACK_IMPORTED_MODULE_4__["default"].multiSet(keyValuePairs).
|
|
1092
|
-
catch((error) => evictStorageAndRetry(error, multiSet, data))
|
|
1158
|
+
catch((error) => evictStorageAndRetry(error, multiSet, data)).
|
|
1159
|
+
then(() => Promise.all(updatePromises));
|
|
1093
1160
|
}
|
|
1094
1161
|
|
|
1095
1162
|
/**
|
|
@@ -1111,7 +1178,7 @@ function applyMerge(existingValue, changes) {
|
|
|
1111
1178
|
// Object values are merged one after the other
|
|
1112
1179
|
// lodash adds a small overhead so we don't use it here
|
|
1113
1180
|
// eslint-disable-next-line prefer-object-spread, rulesdir/prefer-underscore-method
|
|
1114
|
-
return underscore__WEBPACK_IMPORTED_MODULE_1___default().reduce(changes, (modifiedData, change) => (0,
|
|
1181
|
+
return underscore__WEBPACK_IMPORTED_MODULE_1___default().reduce(changes, (modifiedData, change) => (0,_fastMerge__WEBPACK_IMPORTED_MODULE_9__["default"])(modifiedData, change),
|
|
1115
1182
|
existingValue || {});
|
|
1116
1183
|
}
|
|
1117
1184
|
|
|
@@ -1145,19 +1212,19 @@ function merge(key, changes) {
|
|
|
1145
1212
|
// Using the initial value from storage in subsequent merge attempts will lead to an incorrect final merged value.
|
|
1146
1213
|
if (mergeQueue[key]) {
|
|
1147
1214
|
mergeQueue[key].push(changes);
|
|
1148
|
-
return
|
|
1215
|
+
return mergeQueuePromise[key];
|
|
1149
1216
|
}
|
|
1150
1217
|
mergeQueue[key] = [changes];
|
|
1151
1218
|
|
|
1152
|
-
|
|
1219
|
+
mergeQueuePromise[key] = get(key).
|
|
1153
1220
|
then((existingValue) => {
|
|
1154
1221
|
try {
|
|
1155
1222
|
// We first only merge the changes, so we can provide these to the native implementation (SQLite uses only delta changes in "JSON_PATCH" to merge)
|
|
1156
1223
|
let batchedChanges = applyMerge(undefined, mergeQueue[key]);
|
|
1157
1224
|
|
|
1158
|
-
// Clean up the write queue so we
|
|
1159
|
-
// don't apply these changes again
|
|
1225
|
+
// Clean up the write queue, so we don't apply these changes again
|
|
1160
1226
|
delete mergeQueue[key];
|
|
1227
|
+
delete mergeQueuePromise[key];
|
|
1161
1228
|
|
|
1162
1229
|
// After that we merge the batched changes with the existing value
|
|
1163
1230
|
const modifiedData = removeNullObjectValues(applyMerge(existingValue, [batchedChanges]));
|
|
@@ -1173,20 +1240,22 @@ function merge(key, changes) {
|
|
|
1173
1240
|
const hasChanged = _OnyxCache__WEBPACK_IMPORTED_MODULE_3__["default"].hasValueChanged(key, modifiedData);
|
|
1174
1241
|
|
|
1175
1242
|
// This approach prioritizes fast UI changes without waiting for data to be stored in device storage.
|
|
1176
|
-
broadcastUpdate(key, modifiedData, hasChanged, 'merge');
|
|
1243
|
+
const updatePromise = broadcastUpdate(key, modifiedData, hasChanged, 'merge');
|
|
1177
1244
|
|
|
1178
1245
|
// If the value has not changed, calling Storage.setItem() would be redundant and a waste of performance, so return early instead.
|
|
1179
1246
|
if (!hasChanged) {
|
|
1180
|
-
return
|
|
1247
|
+
return updatePromise;
|
|
1181
1248
|
}
|
|
1182
1249
|
|
|
1183
|
-
return _storage__WEBPACK_IMPORTED_MODULE_4__["default"].mergeItem(key, batchedChanges, modifiedData)
|
|
1250
|
+
return _storage__WEBPACK_IMPORTED_MODULE_4__["default"].mergeItem(key, batchedChanges, modifiedData).
|
|
1251
|
+
then(() => updatePromise);
|
|
1184
1252
|
} catch (error) {
|
|
1185
1253
|
_Logger__WEBPACK_IMPORTED_MODULE_5__.logAlert(`An error occurred while applying merge for key: ${key}, Error: ${error}`);
|
|
1254
|
+
return Promise.resolve();
|
|
1186
1255
|
}
|
|
1187
|
-
|
|
1188
|
-
return Promise.resolve();
|
|
1189
1256
|
});
|
|
1257
|
+
|
|
1258
|
+
return mergeQueuePromise[key];
|
|
1190
1259
|
}
|
|
1191
1260
|
|
|
1192
1261
|
/**
|
|
@@ -1199,7 +1268,7 @@ function initializeWithDefaultKeyStates() {
|
|
|
1199
1268
|
then((pairs) => {
|
|
1200
1269
|
const asObject = underscore__WEBPACK_IMPORTED_MODULE_1___default().object(pairs);
|
|
1201
1270
|
|
|
1202
|
-
const merged = (0,
|
|
1271
|
+
const merged = (0,_fastMerge__WEBPACK_IMPORTED_MODULE_9__["default"])(asObject, defaultKeyStates);
|
|
1203
1272
|
_OnyxCache__WEBPACK_IMPORTED_MODULE_3__["default"].merge(merged);
|
|
1204
1273
|
underscore__WEBPACK_IMPORTED_MODULE_1___default().each(merged, (val, key) => keyChanged(key, val));
|
|
1205
1274
|
});
|
|
@@ -1272,19 +1341,21 @@ function clear() {let keysToPreserve = arguments.length > 0 && arguments[0] !==
|
|
|
1272
1341
|
keysToBeClearedFromStorage.push(key);
|
|
1273
1342
|
});
|
|
1274
1343
|
|
|
1344
|
+
const updatePromises = [];
|
|
1345
|
+
|
|
1275
1346
|
// Notify the subscribers for each key/value group so they can receive the new values
|
|
1276
1347
|
underscore__WEBPACK_IMPORTED_MODULE_1___default().each(keyValuesToResetIndividually, (value, key) => {
|
|
1277
|
-
|
|
1348
|
+
updatePromises.push(scheduleSubscriberUpdate(key, value));
|
|
1278
1349
|
});
|
|
1279
1350
|
underscore__WEBPACK_IMPORTED_MODULE_1___default().each(keyValuesToResetAsCollection, (value, key) => {
|
|
1280
|
-
|
|
1351
|
+
updatePromises.push(scheduleNotifyCollectionSubscribers(key, value));
|
|
1281
1352
|
});
|
|
1282
1353
|
|
|
1283
1354
|
const defaultKeyValuePairs = underscore__WEBPACK_IMPORTED_MODULE_1___default().pairs(underscore__WEBPACK_IMPORTED_MODULE_1___default().omit(defaultKeyStates, keysToPreserve));
|
|
1284
1355
|
|
|
1285
1356
|
// Remove only the items that we want cleared from storage, and reset others to default
|
|
1286
1357
|
underscore__WEBPACK_IMPORTED_MODULE_1___default().each(keysToBeClearedFromStorage, (key) => _OnyxCache__WEBPACK_IMPORTED_MODULE_3__["default"].drop(key));
|
|
1287
|
-
return _storage__WEBPACK_IMPORTED_MODULE_4__["default"].removeItems(keysToBeClearedFromStorage).then(() => _storage__WEBPACK_IMPORTED_MODULE_4__["default"].multiSet(defaultKeyValuePairs));
|
|
1358
|
+
return _storage__WEBPACK_IMPORTED_MODULE_4__["default"].removeItems(keysToBeClearedFromStorage).then(() => _storage__WEBPACK_IMPORTED_MODULE_4__["default"].multiSet(defaultKeyValuePairs)).then(() => Promise.all(updatePromises));
|
|
1288
1359
|
});
|
|
1289
1360
|
}
|
|
1290
1361
|
|
|
@@ -1355,13 +1426,14 @@ function mergeCollection(collectionKey, collection) {
|
|
|
1355
1426
|
|
|
1356
1427
|
// Prefill cache if necessary by calling get() on any existing keys and then merge original data to cache
|
|
1357
1428
|
// and update all subscribers
|
|
1358
|
-
Promise.all(underscore__WEBPACK_IMPORTED_MODULE_1___default().map(existingKeys, get)).then(() => {
|
|
1429
|
+
const promiseUpdate = Promise.all(underscore__WEBPACK_IMPORTED_MODULE_1___default().map(existingKeys, get)).then(() => {
|
|
1359
1430
|
_OnyxCache__WEBPACK_IMPORTED_MODULE_3__["default"].merge(collection);
|
|
1360
|
-
|
|
1431
|
+
return scheduleNotifyCollectionSubscribers(collectionKey, collection);
|
|
1361
1432
|
});
|
|
1362
1433
|
|
|
1363
1434
|
return Promise.all(promises).
|
|
1364
|
-
catch((error) => evictStorageAndRetry(error, mergeCollection, collection))
|
|
1435
|
+
catch((error) => evictStorageAndRetry(error, mergeCollection, collection)).
|
|
1436
|
+
then(() => promiseUpdate);
|
|
1365
1437
|
});
|
|
1366
1438
|
}
|
|
1367
1439
|
|
|
@@ -1843,6 +1915,25 @@ function result(parameter) {for (var _len = arguments.length, args = new Array(_
|
|
|
1843
1915
|
|
|
1844
1916
|
|
|
1845
1917
|
|
|
1918
|
+
/***/ }),
|
|
1919
|
+
|
|
1920
|
+
/***/ "./lib/batch.js":
|
|
1921
|
+
/*!**********************!*\
|
|
1922
|
+
!*** ./lib/batch.js ***!
|
|
1923
|
+
\**********************/
|
|
1924
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1925
|
+
|
|
1926
|
+
"use strict";
|
|
1927
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1928
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1929
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
1930
|
+
/* harmony export */ });
|
|
1931
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react-dom */ "react-dom");
|
|
1932
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_0__);
|
|
1933
|
+
|
|
1934
|
+
|
|
1935
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (react_dom__WEBPACK_IMPORTED_MODULE_0__.unstable_batchedUpdates);
|
|
1936
|
+
|
|
1846
1937
|
/***/ }),
|
|
1847
1938
|
|
|
1848
1939
|
/***/ "./lib/createDeferredTask.js":
|
|
@@ -3703,6 +3794,17 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
|
|
|
3703
3794
|
|
|
3704
3795
|
/***/ }),
|
|
3705
3796
|
|
|
3797
|
+
/***/ "react-dom":
|
|
3798
|
+
/*!****************************!*\
|
|
3799
|
+
!*** external "react-dom" ***!
|
|
3800
|
+
\****************************/
|
|
3801
|
+
/***/ ((module) => {
|
|
3802
|
+
|
|
3803
|
+
"use strict";
|
|
3804
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_react_dom__;
|
|
3805
|
+
|
|
3806
|
+
/***/ }),
|
|
3807
|
+
|
|
3706
3808
|
/***/ "underscore":
|
|
3707
3809
|
/*!*****************************!*\
|
|
3708
3810
|
!*** external "underscore" ***!
|