react-native-onyx 1.0.49 → 1.0.50

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.
@@ -1300,6 +1300,14 @@ function update(data) {
1300
1300
  return clearPromise.then(() => Promise.all(underscore__WEBPACK_IMPORTED_MODULE_2___default().map(promises, (p) => p())));
1301
1301
  }
1302
1302
 
1303
+ /**
1304
+ * When set these keys will not be persisted to storage
1305
+ * @param {string[]} keyList
1306
+ */
1307
+ function setMemoryOnlyKeys(keyList) {
1308
+ _storage__WEBPACK_IMPORTED_MODULE_5__["default"].setMemoryOnlyKeys(keyList);
1309
+ }
1310
+
1303
1311
  /**
1304
1312
  * Initialize the store with actions and listening for storage events
1305
1313
  *
@@ -1387,7 +1395,8 @@ const Onyx = {
1387
1395
  addToEvictionBlockList,
1388
1396
  removeFromEvictionBlockList,
1389
1397
  isSafeEvictionKey,
1390
- METHOD
1398
+ METHOD,
1399
+ setMemoryOnlyKeys
1391
1400
  };
1392
1401
 
1393
1402
  /**
@@ -2132,7 +2141,8 @@ __webpack_require__.r(__webpack_exports__);
2132
2141
  /* harmony import */ var localforage_removeitems__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! localforage-removeitems */ "localforage-removeitems");
2133
2142
  /* harmony import */ var localforage_removeitems__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(localforage_removeitems__WEBPACK_IMPORTED_MODULE_2__);
2134
2143
  /* harmony import */ var _SyncQueue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../SyncQueue */ "./lib/SyncQueue.js");
2135
- /* harmony import */ var _fastMerge__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../fastMerge */ "./lib/fastMerge.js");
2144
+ /* harmony import */ var _Str__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Str */ "./lib/Str.js");
2145
+ /* harmony import */ var _fastMerge__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../fastMerge */ "./lib/fastMerge.js");
2136
2146
  /**
2137
2147
  * @file
2138
2148
  * The storage provider based on localforage allows us to store most anything in its
@@ -2145,12 +2155,18 @@ __webpack_require__.r(__webpack_exports__);
2145
2155
 
2146
2156
 
2147
2157
 
2158
+
2148
2159
  (0,localforage_removeitems__WEBPACK_IMPORTED_MODULE_2__.extendPrototype)((localforage__WEBPACK_IMPORTED_MODULE_0___default()));
2149
2160
 
2150
2161
  localforage__WEBPACK_IMPORTED_MODULE_0___default().config({
2151
2162
  name: 'OnyxDB'
2152
2163
  });
2153
2164
 
2165
+ /**
2166
+ * Keys that will not ever be persisted to disk.
2167
+ */
2168
+ let memoryOnlyKeys = [];
2169
+
2154
2170
  const provider = {
2155
2171
  /**
2156
2172
  * Writing very quickly to IndexedDB causes performance issues and can lock up the page and lead to jank.
@@ -2158,6 +2174,10 @@ const provider = {
2158
2174
  * to the next.
2159
2175
  */
2160
2176
  setItemQueue: new _SyncQueue__WEBPACK_IMPORTED_MODULE_3__["default"]((_ref) => {let { key, value, shouldMerge } = _ref;
2177
+ if (underscore__WEBPACK_IMPORTED_MODULE_1___default().find(memoryOnlyKeys, (noCacheKey) => _Str__WEBPACK_IMPORTED_MODULE_4__.startsWith(key, noCacheKey))) {
2178
+ return Promise.resolve();
2179
+ }
2180
+
2161
2181
  if (shouldMerge) {
2162
2182
  return localforage__WEBPACK_IMPORTED_MODULE_0___default().getItem(key).
2163
2183
  then((existingValue) => {
@@ -2165,7 +2185,7 @@ const provider = {
2165
2185
 
2166
2186
  // lodash adds a small overhead so we don't use it here
2167
2187
  // eslint-disable-next-line prefer-object-spread, rulesdir/prefer-underscore-method
2168
- ? Object.assign({}, (0,_fastMerge__WEBPACK_IMPORTED_MODULE_4__["default"])(existingValue, value)) :
2188
+ ? Object.assign({}, (0,_fastMerge__WEBPACK_IMPORTED_MODULE_5__["default"])(existingValue, value)) :
2169
2189
  value;
2170
2190
  return localforage__WEBPACK_IMPORTED_MODULE_0___default().setItem(key, newValue);
2171
2191
  });
@@ -2259,6 +2279,13 @@ const provider = {
2259
2279
  */
2260
2280
  setItem(key, value) {
2261
2281
  return this.setItemQueue.push({ key, value });
2282
+ },
2283
+
2284
+ /**
2285
+ * @param {string[]} keyList
2286
+ */
2287
+ setMemoryOnlyKeys(keyList) {
2288
+ memoryOnlyKeys = keyList;
2262
2289
  }
2263
2290
  };
2264
2291