react-native-onyx 1.0.60 → 1.0.62
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 +69 -205
- 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 +1 -1
- package/lib/storage/WebStorage.js +2 -2
- package/lib/storage/__mocks__/index.js +15 -15
- package/lib/storage/providers/IDBKeyVal.js +110 -0
- package/lib/withOnyx.js +12 -1
- package/package.json +6 -10
- package/lib/storage/providers/LocalForage.js +0 -158
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("
|
|
3
|
+
module.exports = factory(require("fast-equals"), require("underscore"), require("idb-keyval"), require("lodash/transform"), require("react"));
|
|
4
4
|
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define(["fast-equals", "underscore", "
|
|
5
|
+
define(["fast-equals", "underscore", "idb-keyval", "lodash/transform", "react"], factory);
|
|
6
6
|
else if(typeof exports === 'object')
|
|
7
|
-
exports["react-native-onyx/web"] = factory(require("fast-equals"), require("underscore"), require("
|
|
7
|
+
exports["react-native-onyx/web"] = factory(require("fast-equals"), require("underscore"), require("idb-keyval"), require("lodash/transform"), require("react"));
|
|
8
8
|
else
|
|
9
|
-
root["react-native-onyx/web"] = factory(root["fast-equals"], root["underscore"], root["
|
|
10
|
-
})(self, (__WEBPACK_EXTERNAL_MODULE_fast_equals__, __WEBPACK_EXTERNAL_MODULE_underscore__,
|
|
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__) => {
|
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
|
12
12
|
/******/ var __webpack_modules__ = ({
|
|
13
13
|
|
|
@@ -983,7 +983,6 @@ function broadcastUpdate(key, value, hasChanged, method) {
|
|
|
983
983
|
}
|
|
984
984
|
|
|
985
985
|
/**
|
|
986
|
-
* @private
|
|
987
986
|
* @param {String} key
|
|
988
987
|
* @returns {Boolean}
|
|
989
988
|
*/
|
|
@@ -1490,7 +1489,8 @@ const Onyx = {
|
|
|
1490
1489
|
isSafeEvictionKey,
|
|
1491
1490
|
METHOD,
|
|
1492
1491
|
setMemoryOnlyKeys,
|
|
1493
|
-
tryGetCachedValue
|
|
1492
|
+
tryGetCachedValue,
|
|
1493
|
+
hasPendingMergeForKey
|
|
1494
1494
|
};
|
|
1495
1495
|
|
|
1496
1496
|
/**
|
|
@@ -1812,79 +1812,6 @@ function result(parameter) {for (var _len = arguments.length, args = new Array(_
|
|
|
1812
1812
|
|
|
1813
1813
|
|
|
1814
1814
|
|
|
1815
|
-
/***/ }),
|
|
1816
|
-
|
|
1817
|
-
/***/ "./lib/SyncQueue.js":
|
|
1818
|
-
/*!**************************!*\
|
|
1819
|
-
!*** ./lib/SyncQueue.js ***!
|
|
1820
|
-
\**************************/
|
|
1821
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1822
|
-
|
|
1823
|
-
"use strict";
|
|
1824
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1825
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1826
|
-
/* harmony export */ "default": () => (/* binding */ SyncQueue)
|
|
1827
|
-
/* harmony export */ });
|
|
1828
|
-
/**
|
|
1829
|
-
* Synchronous queue that can be used to ensure promise based tasks are run in sequence.
|
|
1830
|
-
* Pass to the constructor a function that returns a promise to run the task then add data.
|
|
1831
|
-
*
|
|
1832
|
-
* @example
|
|
1833
|
-
*
|
|
1834
|
-
* const queue = new SyncQueue(({key, val}) => {
|
|
1835
|
-
* return someAsyncProcess(key, val);
|
|
1836
|
-
* });
|
|
1837
|
-
*
|
|
1838
|
-
* queue.push({key: 1, val: '1'});
|
|
1839
|
-
* queue.push({key: 2, val: '2'});
|
|
1840
|
-
*/
|
|
1841
|
-
class SyncQueue {
|
|
1842
|
-
/**
|
|
1843
|
-
* @param {Function} run - must return a promise
|
|
1844
|
-
*/
|
|
1845
|
-
constructor(run) {
|
|
1846
|
-
this.queue = [];
|
|
1847
|
-
this.isProcessing = false;
|
|
1848
|
-
this.run = run;
|
|
1849
|
-
}
|
|
1850
|
-
|
|
1851
|
-
/**
|
|
1852
|
-
* Stop the queue from being processed and clear out any existing tasks
|
|
1853
|
-
*/
|
|
1854
|
-
abort() {
|
|
1855
|
-
this.queue = [];
|
|
1856
|
-
this.isProcessing = false;
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
process() {
|
|
1860
|
-
if (this.isProcessing || this.queue.length === 0) {
|
|
1861
|
-
return;
|
|
1862
|
-
}
|
|
1863
|
-
|
|
1864
|
-
this.isProcessing = true;
|
|
1865
|
-
|
|
1866
|
-
const { data, resolve, reject } = this.queue.shift();
|
|
1867
|
-
this.run(data).
|
|
1868
|
-
then(resolve).
|
|
1869
|
-
catch(reject).
|
|
1870
|
-
finally(() => {
|
|
1871
|
-
this.isProcessing = false;
|
|
1872
|
-
this.process();
|
|
1873
|
-
});
|
|
1874
|
-
}
|
|
1875
|
-
|
|
1876
|
-
/**
|
|
1877
|
-
* @param {*} data
|
|
1878
|
-
* @returns {Promise}
|
|
1879
|
-
*/
|
|
1880
|
-
push(data) {
|
|
1881
|
-
return new Promise((resolve, reject) => {
|
|
1882
|
-
this.queue.push({ resolve, reject, data });
|
|
1883
|
-
this.process();
|
|
1884
|
-
});
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
1815
|
/***/ }),
|
|
1889
1816
|
|
|
1890
1817
|
/***/ "./lib/createDeferredTask.js":
|
|
@@ -2119,9 +2046,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2119
2046
|
/* harmony export */ });
|
|
2120
2047
|
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "underscore");
|
|
2121
2048
|
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(underscore__WEBPACK_IMPORTED_MODULE_0__);
|
|
2122
|
-
/* harmony import */ var
|
|
2049
|
+
/* harmony import */ var _providers_IDBKeyVal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./providers/IDBKeyVal */ "./lib/storage/providers/IDBKeyVal.js");
|
|
2123
2050
|
/**
|
|
2124
|
-
* This file is here to wrap
|
|
2051
|
+
* This file is here to wrap IDBKeyVal with a layer that provides data-changed events like the ones that exist
|
|
2125
2052
|
* when using LocalStorage APIs in the browser. These events are great because multiple tabs can listen for when
|
|
2126
2053
|
* data changes and then stay up-to-date with everything happening in Onyx.
|
|
2127
2054
|
*/
|
|
@@ -2146,20 +2073,20 @@ function raiseStorageSyncManyKeysEvent(onyxKeys) {
|
|
|
2146
2073
|
}
|
|
2147
2074
|
|
|
2148
2075
|
const webStorage = {
|
|
2149
|
-
...
|
|
2076
|
+
..._providers_IDBKeyVal__WEBPACK_IMPORTED_MODULE_1__["default"],
|
|
2150
2077
|
|
|
2151
2078
|
/**
|
|
2152
2079
|
* @param {Function} onStorageKeyChanged Storage synchronization mechanism keeping all opened tabs in sync
|
|
2153
2080
|
*/
|
|
2154
2081
|
keepInstancesSync(onStorageKeyChanged) {
|
|
2155
2082
|
// Override set, remove and clear to raise storage events that we intercept in other tabs
|
|
2156
|
-
this.setItem = (key, value) =>
|
|
2083
|
+
this.setItem = (key, value) => _providers_IDBKeyVal__WEBPACK_IMPORTED_MODULE_1__["default"].setItem(key, value).
|
|
2157
2084
|
then(() => raiseStorageSyncEvent(key));
|
|
2158
2085
|
|
|
2159
|
-
this.removeItem = (key) =>
|
|
2086
|
+
this.removeItem = (key) => _providers_IDBKeyVal__WEBPACK_IMPORTED_MODULE_1__["default"].removeItem(key).
|
|
2160
2087
|
then(() => raiseStorageSyncEvent(key));
|
|
2161
2088
|
|
|
2162
|
-
this.removeItems = (keys) =>
|
|
2089
|
+
this.removeItems = (keys) => _providers_IDBKeyVal__WEBPACK_IMPORTED_MODULE_1__["default"].removeItems(keys).
|
|
2163
2090
|
then(() => raiseStorageSyncManyKeysEvent(keys));
|
|
2164
2091
|
|
|
2165
2092
|
// If we just call Storage.clear other tabs will have no idea which keys were available previously
|
|
@@ -2169,11 +2096,11 @@ const webStorage = {
|
|
|
2169
2096
|
let allKeys;
|
|
2170
2097
|
|
|
2171
2098
|
// They keys must be retreived before storage is cleared or else the list of keys would be empty
|
|
2172
|
-
return
|
|
2099
|
+
return _providers_IDBKeyVal__WEBPACK_IMPORTED_MODULE_1__["default"].getAllKeys().
|
|
2173
2100
|
then((keys) => {
|
|
2174
2101
|
allKeys = keys;
|
|
2175
2102
|
}).
|
|
2176
|
-
then(() =>
|
|
2103
|
+
then(() => _providers_IDBKeyVal__WEBPACK_IMPORTED_MODULE_1__["default"].clear()).
|
|
2177
2104
|
then(() => {
|
|
2178
2105
|
// Now that storage is cleared, the storage sync event can happen which is a more atomic action
|
|
2179
2106
|
// for other browser tabs
|
|
@@ -2189,7 +2116,7 @@ const webStorage = {
|
|
|
2189
2116
|
}
|
|
2190
2117
|
|
|
2191
2118
|
const onyxKey = event.newValue;
|
|
2192
|
-
|
|
2119
|
+
_providers_IDBKeyVal__WEBPACK_IMPORTED_MODULE_1__["default"].getItem(onyxKey).
|
|
2193
2120
|
then((value) => onStorageKeyChanged(onyxKey, value));
|
|
2194
2121
|
});
|
|
2195
2122
|
}
|
|
@@ -2217,10 +2144,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2217
2144
|
|
|
2218
2145
|
/***/ }),
|
|
2219
2146
|
|
|
2220
|
-
/***/ "./lib/storage/providers/
|
|
2221
|
-
|
|
2222
|
-
!*** ./lib/storage/providers/
|
|
2223
|
-
|
|
2147
|
+
/***/ "./lib/storage/providers/IDBKeyVal.js":
|
|
2148
|
+
/*!********************************************!*\
|
|
2149
|
+
!*** ./lib/storage/providers/IDBKeyVal.js ***!
|
|
2150
|
+
\********************************************/
|
|
2224
2151
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2225
2152
|
|
|
2226
2153
|
"use strict";
|
|
@@ -2228,102 +2155,55 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2228
2155
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2229
2156
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
2230
2157
|
/* harmony export */ });
|
|
2231
|
-
/* harmony import */ var
|
|
2232
|
-
/* harmony import */ var
|
|
2158
|
+
/* harmony import */ var idb_keyval__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! idb-keyval */ "idb-keyval");
|
|
2159
|
+
/* harmony import */ var idb_keyval__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(idb_keyval__WEBPACK_IMPORTED_MODULE_0__);
|
|
2233
2160
|
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ "underscore");
|
|
2234
2161
|
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(underscore__WEBPACK_IMPORTED_MODULE_1__);
|
|
2235
|
-
/* harmony import */ var
|
|
2236
|
-
/* harmony import */ var localforage_removeitems__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(localforage_removeitems__WEBPACK_IMPORTED_MODULE_2__);
|
|
2237
|
-
/* harmony import */ var _SyncQueue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../SyncQueue */ "./lib/SyncQueue.js");
|
|
2238
|
-
/* harmony import */ var _Str__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Str */ "./lib/Str.js");
|
|
2239
|
-
/* harmony import */ var _fastMerge__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../fastMerge */ "./lib/fastMerge.js");
|
|
2240
|
-
/**
|
|
2241
|
-
* @file
|
|
2242
|
-
* The storage provider based on localforage allows us to store most anything in its
|
|
2243
|
-
* natural form in the underlying DB without having to stringify or de-stringify it
|
|
2244
|
-
*/
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2162
|
+
/* harmony import */ var _fastMerge__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../fastMerge */ "./lib/fastMerge.js");
|
|
2248
2163
|
|
|
2249
2164
|
|
|
2250
2165
|
|
|
2251
2166
|
|
|
2252
|
-
|
|
2253
|
-
(0,localforage_removeitems__WEBPACK_IMPORTED_MODULE_2__.extendPrototype)((localforage__WEBPACK_IMPORTED_MODULE_0___default()));
|
|
2254
|
-
|
|
2255
|
-
localforage__WEBPACK_IMPORTED_MODULE_0___default().config({
|
|
2256
|
-
name: 'OnyxDB'
|
|
2257
|
-
});
|
|
2258
|
-
|
|
2259
|
-
/**
|
|
2260
|
-
* Keys that will not ever be persisted to disk.
|
|
2261
|
-
*/
|
|
2262
|
-
let memoryOnlyKeys = [];
|
|
2167
|
+
const customStore = (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.createStore)('OnyxDB', 'keyvaluepairs');
|
|
2263
2168
|
|
|
2264
2169
|
const provider = {
|
|
2265
|
-
/**
|
|
2266
|
-
* Writing very quickly to IndexedDB causes performance issues and can lock up the page and lead to jank.
|
|
2267
|
-
* So, we are slowing this process down by waiting until one write is complete before moving on
|
|
2268
|
-
* to the next.
|
|
2269
|
-
*/
|
|
2270
|
-
setItemQueue: new _SyncQueue__WEBPACK_IMPORTED_MODULE_3__["default"]((_ref) => {let { key, value, shouldMerge } = _ref;
|
|
2271
|
-
if (underscore__WEBPACK_IMPORTED_MODULE_1___default().find(memoryOnlyKeys, (noCacheKey) => _Str__WEBPACK_IMPORTED_MODULE_4__.startsWith(key, noCacheKey))) {
|
|
2272
|
-
return Promise.resolve();
|
|
2273
|
-
}
|
|
2274
|
-
|
|
2275
|
-
if (shouldMerge) {
|
|
2276
|
-
return localforage__WEBPACK_IMPORTED_MODULE_0___default().getItem(key).
|
|
2277
|
-
then((existingValue) => {
|
|
2278
|
-
const newValue = underscore__WEBPACK_IMPORTED_MODULE_1___default().isObject(existingValue)
|
|
2279
|
-
|
|
2280
|
-
// lodash adds a small overhead so we don't use it here
|
|
2281
|
-
// eslint-disable-next-line prefer-object-spread, rulesdir/prefer-underscore-method
|
|
2282
|
-
? Object.assign({}, (0,_fastMerge__WEBPACK_IMPORTED_MODULE_5__["default"])(existingValue, value)) :
|
|
2283
|
-
value;
|
|
2284
|
-
return localforage__WEBPACK_IMPORTED_MODULE_0___default().setItem(key, newValue);
|
|
2285
|
-
});
|
|
2286
|
-
}
|
|
2287
|
-
|
|
2288
|
-
return localforage__WEBPACK_IMPORTED_MODULE_0___default().setItem(key, value);
|
|
2289
|
-
}),
|
|
2290
|
-
|
|
2291
2170
|
/**
|
|
2292
2171
|
* Sets the value for a given key. The only requirement is that the value should be serializable to JSON string
|
|
2293
2172
|
* @param {String} key
|
|
2294
2173
|
* @param {*} value
|
|
2295
2174
|
* @return {Promise<void>}
|
|
2296
2175
|
*/
|
|
2297
|
-
setItem(key, value)
|
|
2298
|
-
return this.setItemQueue.push({ key, value });
|
|
2299
|
-
},
|
|
2176
|
+
setItem: (key, value) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.set)(key, value, customStore),
|
|
2300
2177
|
|
|
2301
2178
|
/**
|
|
2302
|
-
* Get multiple key-value pairs for the give array of keys in a batch
|
|
2303
|
-
*
|
|
2179
|
+
* Get multiple key-value pairs for the give array of keys in a batch.
|
|
2180
|
+
* This is optimized to use only one database transaction.
|
|
2181
|
+
* @param {String[]} keysParam
|
|
2304
2182
|
* @return {Promise<Array<[key, value]>>}
|
|
2305
2183
|
*/
|
|
2306
|
-
multiGet(
|
|
2307
|
-
|
|
2308
|
-
keys,
|
|
2309
|
-
(key) => localforage__WEBPACK_IMPORTED_MODULE_0___default().getItem(key).
|
|
2310
|
-
then((value) => [key, value]));
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
return Promise.all(pairs);
|
|
2314
|
-
},
|
|
2184
|
+
multiGet: (keysParam) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.getMany)(keysParam, customStore).
|
|
2185
|
+
then((values) => underscore__WEBPACK_IMPORTED_MODULE_1___default().map(values, (value, index) => [keysParam[index], value])),
|
|
2315
2186
|
|
|
2316
2187
|
/**
|
|
2317
2188
|
* Multiple merging of existing and new values in a batch
|
|
2318
2189
|
* @param {Array<[key, value]>} pairs
|
|
2319
2190
|
* @return {Promise<void>}
|
|
2320
2191
|
*/
|
|
2321
|
-
multiMerge(pairs) {
|
|
2322
|
-
|
|
2192
|
+
multiMerge: (pairs) => customStore('readwrite', (store) => {
|
|
2193
|
+
// Note: we are using the manual store transaction here, to fit the read and update
|
|
2194
|
+
// of the items in one transaction to achieve best performance.
|
|
2323
2195
|
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2196
|
+
const getValues = Promise.all(underscore__WEBPACK_IMPORTED_MODULE_1___default().map(pairs, (_ref) => {let [key] = _ref;return (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.promisifyRequest)(store.get(key));}));
|
|
2197
|
+
|
|
2198
|
+
return getValues.then((values) => {
|
|
2199
|
+
const upsertMany = underscore__WEBPACK_IMPORTED_MODULE_1___default().map(pairs, (_ref2, index) => {let [key, value] = _ref2;
|
|
2200
|
+
const prev = values[index];
|
|
2201
|
+
const newValue = underscore__WEBPACK_IMPORTED_MODULE_1___default().isObject(prev) ? (0,_fastMerge__WEBPACK_IMPORTED_MODULE_2__["default"])(prev, value) : value;
|
|
2202
|
+
return (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.promisifyRequest)(store.put(newValue, key));
|
|
2203
|
+
});
|
|
2204
|
+
return Promise.all(upsertMany);
|
|
2205
|
+
});
|
|
2206
|
+
}),
|
|
2327
2207
|
|
|
2328
2208
|
/**
|
|
2329
2209
|
* Merging an existing value with a new one
|
|
@@ -2333,7 +2213,7 @@ const provider = {
|
|
|
2333
2213
|
* @return {Promise<void>}
|
|
2334
2214
|
*/
|
|
2335
2215
|
mergeItem(key, _changes, modifiedData) {
|
|
2336
|
-
return
|
|
2216
|
+
return provider.multiMerge([[key, modifiedData]]);
|
|
2337
2217
|
},
|
|
2338
2218
|
|
|
2339
2219
|
/**
|
|
@@ -2341,57 +2221,41 @@ const provider = {
|
|
|
2341
2221
|
* @param {Array<[key, value]>} pairs
|
|
2342
2222
|
* @return {Promise<void>}
|
|
2343
2223
|
*/
|
|
2344
|
-
multiSet(pairs)
|
|
2345
|
-
// We're returning Promise.resolve, otherwise the array of task results will be returned to the caller
|
|
2346
|
-
const tasks = underscore__WEBPACK_IMPORTED_MODULE_1___default().map(pairs, (_ref3) => {let [key, value] = _ref3;return this.setItem(key, value);});
|
|
2347
|
-
return Promise.all(tasks).then(() => Promise.resolve());
|
|
2348
|
-
},
|
|
2224
|
+
multiSet: (pairs) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.setMany)(pairs, customStore),
|
|
2349
2225
|
|
|
2350
2226
|
/**
|
|
2351
2227
|
* Clear everything from storage and also stops the SyncQueue from adding anything more to storage
|
|
2352
2228
|
* @returns {Promise<void>}
|
|
2353
2229
|
*/
|
|
2354
|
-
clear()
|
|
2355
|
-
this.setItemQueue.abort();
|
|
2356
|
-
return localforage__WEBPACK_IMPORTED_MODULE_0___default().clear();
|
|
2357
|
-
},
|
|
2230
|
+
clear: () => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.clear)(customStore),
|
|
2358
2231
|
|
|
2359
2232
|
/**
|
|
2360
2233
|
* Returns all keys available in storage
|
|
2361
2234
|
* @returns {Promise<String[]>}
|
|
2362
2235
|
*/
|
|
2363
|
-
getAllKeys: (
|
|
2236
|
+
getAllKeys: () => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.keys)(customStore),
|
|
2364
2237
|
|
|
2365
2238
|
/**
|
|
2366
2239
|
* Get the value of a given key or return `null` if it's not available in storage
|
|
2367
2240
|
* @param {String} key
|
|
2368
2241
|
* @return {Promise<*>}
|
|
2369
2242
|
*/
|
|
2370
|
-
getItem: (
|
|
2243
|
+
getItem: (key) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.get)(key, customStore),
|
|
2371
2244
|
|
|
2372
2245
|
/**
|
|
2373
2246
|
* Remove given key and it's value from storage
|
|
2374
2247
|
* @param {String} key
|
|
2375
2248
|
* @returns {Promise<void>}
|
|
2376
2249
|
*/
|
|
2377
|
-
removeItem: (
|
|
2250
|
+
removeItem: (key) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.del)(key, customStore),
|
|
2378
2251
|
|
|
2379
2252
|
/**
|
|
2380
2253
|
* Remove given keys and their values from storage
|
|
2381
2254
|
*
|
|
2382
|
-
* @param {Array}
|
|
2255
|
+
* @param {Array} keysParam
|
|
2383
2256
|
* @returns {Promise}
|
|
2384
2257
|
*/
|
|
2385
|
-
removeItems(
|
|
2386
|
-
return localforage__WEBPACK_IMPORTED_MODULE_0___default().removeItems(keys);
|
|
2387
|
-
},
|
|
2388
|
-
|
|
2389
|
-
/**
|
|
2390
|
-
* @param {string[]} keyList
|
|
2391
|
-
*/
|
|
2392
|
-
setMemoryOnlyKeys(keyList) {
|
|
2393
|
-
memoryOnlyKeys = keyList;
|
|
2394
|
-
}
|
|
2258
|
+
removeItems: (keysParam) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.delMany)(keysParam, customStore)
|
|
2395
2259
|
};
|
|
2396
2260
|
|
|
2397
2261
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (provider);
|
|
@@ -2460,7 +2324,18 @@ function getDisplayName(component) {
|
|
|
2460
2324
|
const key = _Str__WEBPACK_IMPORTED_MODULE_3__.result(mapping.key, props);
|
|
2461
2325
|
const value = _Onyx__WEBPACK_IMPORTED_MODULE_4__["default"].tryGetCachedValue(key, mapping);
|
|
2462
2326
|
|
|
2463
|
-
|
|
2327
|
+
/**
|
|
2328
|
+
* If we have a pending merge for a key it could mean that data is being set via Onyx.merge() and someone expects a component to have this data immediately.
|
|
2329
|
+
*
|
|
2330
|
+
* @example
|
|
2331
|
+
*
|
|
2332
|
+
* Onyx.merge('report_123', value);
|
|
2333
|
+
* Navigation.navigate(route); // Where "route" expects the "value" to be available immediately once rendered.
|
|
2334
|
+
*
|
|
2335
|
+
* In reality, Onyx.merge() will only update the subscriber after all merges have been batched and the previous value is retrieved via a get() (returns a promise).
|
|
2336
|
+
* So, we won't use the cache optimization here as it will lead us to arbitrarily defer various actions in the application code.
|
|
2337
|
+
*/
|
|
2338
|
+
if (value !== undefined && !_Onyx__WEBPACK_IMPORTED_MODULE_4__["default"].hasPendingMergeForKey(key)) {
|
|
2464
2339
|
// eslint-disable-next-line no-param-reassign
|
|
2465
2340
|
resultObj[propertyName] = value;
|
|
2466
2341
|
}
|
|
@@ -3733,25 +3608,14 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_fast_equals__;
|
|
|
3733
3608
|
|
|
3734
3609
|
/***/ }),
|
|
3735
3610
|
|
|
3736
|
-
/***/ "
|
|
3737
|
-
|
|
3738
|
-
!*** external "
|
|
3739
|
-
|
|
3740
|
-
/***/ ((module) => {
|
|
3741
|
-
|
|
3742
|
-
"use strict";
|
|
3743
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_localforage__;
|
|
3744
|
-
|
|
3745
|
-
/***/ }),
|
|
3746
|
-
|
|
3747
|
-
/***/ "localforage-removeitems":
|
|
3748
|
-
/*!******************************************!*\
|
|
3749
|
-
!*** external "localforage-removeitems" ***!
|
|
3750
|
-
\******************************************/
|
|
3611
|
+
/***/ "idb-keyval":
|
|
3612
|
+
/*!*****************************!*\
|
|
3613
|
+
!*** external "idb-keyval" ***!
|
|
3614
|
+
\*****************************/
|
|
3751
3615
|
/***/ ((module) => {
|
|
3752
3616
|
|
|
3753
3617
|
"use strict";
|
|
3754
|
-
module.exports =
|
|
3618
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_idb_keyval__;
|
|
3755
3619
|
|
|
3756
3620
|
/***/ }),
|
|
3757
3621
|
|