react-native-onyx 2.0.86 → 2.0.87
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 +14 -1
- package/dist/OnyxUtils.d.ts +3 -3
- package/package.json +1 -1
package/dist/Onyx.js
CHANGED
|
@@ -500,6 +500,10 @@ function updateSnapshots(data) {
|
|
|
500
500
|
if (!snapshotData || !snapshotData[key]) {
|
|
501
501
|
return;
|
|
502
502
|
}
|
|
503
|
+
if (Array.isArray(value)) {
|
|
504
|
+
updatedData[key] = value;
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
503
507
|
const oldValue = updatedData[key] || {};
|
|
504
508
|
const newValue = (0, pick_1.default)(value, Object.keys(snapshotData[key]));
|
|
505
509
|
updatedData = Object.assign(Object.assign({}, updatedData), { [key]: Object.assign(oldValue, newValue) });
|
|
@@ -661,7 +665,16 @@ function setCollection(collectionKey, collection) {
|
|
|
661
665
|
}
|
|
662
666
|
mutableCollection[key] = null;
|
|
663
667
|
});
|
|
664
|
-
|
|
668
|
+
const keyValuePairs = OnyxUtils_1.default.prepareKeyValuePairsForStorage(mutableCollection, true);
|
|
669
|
+
const previousCollection = OnyxUtils_1.default.getCachedCollection(collectionKey);
|
|
670
|
+
keyValuePairs.forEach(([key, value]) => OnyxCache_1.default.set(key, value));
|
|
671
|
+
const updatePromise = OnyxUtils_1.default.scheduleNotifyCollectionSubscribers(collectionKey, mutableCollection, previousCollection);
|
|
672
|
+
return storage_1.default.multiSet(keyValuePairs)
|
|
673
|
+
.catch((error) => OnyxUtils_1.default.evictStorageAndRetry(error, setCollection, collectionKey, collection))
|
|
674
|
+
.then(() => {
|
|
675
|
+
OnyxUtils_1.default.sendActionToDevTools(OnyxUtils_1.default.METHOD.SET_COLLECTION, undefined, mutableCollection);
|
|
676
|
+
return updatePromise;
|
|
677
|
+
});
|
|
665
678
|
});
|
|
666
679
|
}
|
|
667
680
|
const Onyx = {
|
package/dist/OnyxUtils.d.ts
CHANGED
|
@@ -48,8 +48,8 @@ declare function initStoreValues(keys: DeepRecord<string, OnyxKey>, initialKeySt
|
|
|
48
48
|
* @param value - contains the change that was made by the method
|
|
49
49
|
* @param mergedValue - (optional) value that was written in the storage after a merge method was executed.
|
|
50
50
|
*/
|
|
51
|
-
declare function sendActionToDevTools(method: typeof METHOD.MERGE_COLLECTION | typeof METHOD.MULTI_SET, key: undefined, value: OnyxCollection<KeyValueMapping[OnyxKey]>, mergedValue?: undefined): void;
|
|
52
|
-
declare function sendActionToDevTools(method: Exclude<OnyxMethod, typeof METHOD.MERGE_COLLECTION | typeof METHOD.MULTI_SET>, key: OnyxKey, value: OnyxEntry<KeyValueMapping[OnyxKey]>, mergedValue?: OnyxEntry<KeyValueMapping[OnyxKey]>): void;
|
|
51
|
+
declare function sendActionToDevTools(method: typeof METHOD.MERGE_COLLECTION | typeof METHOD.MULTI_SET | typeof METHOD.SET_COLLECTION, key: undefined, value: OnyxCollection<KeyValueMapping[OnyxKey]>, mergedValue?: undefined): void;
|
|
52
|
+
declare function sendActionToDevTools(method: Exclude<OnyxMethod, typeof METHOD.MERGE_COLLECTION | typeof METHOD.MULTI_SET | typeof METHOD.SET_COLLECTION>, key: OnyxKey, value: OnyxEntry<KeyValueMapping[OnyxKey]>, mergedValue?: OnyxEntry<KeyValueMapping[OnyxKey]>): void;
|
|
53
53
|
/**
|
|
54
54
|
* We are batching together onyx updates. This helps with use cases where we schedule onyx updates after each other.
|
|
55
55
|
* This happens for example in the Onyx.update function, where we process API responses that might contain a lot of
|
|
@@ -167,7 +167,7 @@ declare function reportStorageQuota(): Promise<void>;
|
|
|
167
167
|
* evicting some data from Onyx and then retrying to do
|
|
168
168
|
* whatever it is we attempted to do.
|
|
169
169
|
*/
|
|
170
|
-
declare function evictStorageAndRetry<TMethod extends typeof Onyx.set | typeof Onyx.multiSet | typeof Onyx.mergeCollection>(error: Error, onyxMethod: TMethod, ...args: Parameters<TMethod>): Promise<void>;
|
|
170
|
+
declare function evictStorageAndRetry<TMethod extends typeof Onyx.set | typeof Onyx.multiSet | typeof Onyx.mergeCollection | typeof Onyx.setCollection>(error: Error, onyxMethod: TMethod, ...args: Parameters<TMethod>): Promise<void>;
|
|
171
171
|
/**
|
|
172
172
|
* Notifies subscribers and writes current value to cache
|
|
173
173
|
*/
|