react-native-onyx 3.0.116 → 3.0.117
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/API.md +15 -5
- package/README.md +8 -8
- package/dist/Onyx.d.ts +17 -14
- package/dist/Onyx.js +125 -38
- package/dist/OnyxCache.d.ts +2 -2
- package/dist/OnyxCache.js +4 -9
- package/dist/OnyxUtils.d.ts +17 -55
- package/dist/OnyxUtils.js +63 -352
- package/dist/PendingWrites.d.ts +35 -0
- package/dist/PendingWrites.js +103 -0
- package/dist/index.d.ts +1 -2
- package/dist/types.d.ts +10 -13
- package/dist/useOnyx.d.ts +11 -10
- package/dist/useOnyx.js +68 -193
- package/package.json +4 -2
- package/dist/OnyxConnectionManager.d.ts +0 -78
- package/dist/OnyxConnectionManager.js +0 -189
- package/dist/OnyxSnapshotCache.d.ts +0 -75
- package/dist/OnyxSnapshotCache.js +0 -125
- package/dist/createMemoizedSelector.d.ts +0 -18
- package/dist/createMemoizedSelector.js +0 -37
- package/dist/memoizedShallowEqual.d.ts +0 -5
- package/dist/memoizedShallowEqual.js +0 -34
package/dist/OnyxUtils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ValueOf } from 'type-fest';
|
|
2
2
|
import type Onyx from './Onyx';
|
|
3
|
-
import type { CollectionKeyBase,
|
|
3
|
+
import type { CollectionKeyBase, DeepRecord, KeyValueMapping, MultiMergeReplaceNullPatches, OnyxCollection, OnyxEntry, OnyxInput, OnyxKey, OnyxMergeCollectionInput, OnyxUpdate, OnyxValue, Selector, MergeCollectionWithPatchesParams, SetCollectionParams, SetParams, OnyxMultiSetInput, RetriableOnyxOperation } from './types';
|
|
4
4
|
import type { FastMergeResult } from './utils';
|
|
5
5
|
import type { DeferredTask } from './createDeferredTask';
|
|
6
6
|
import type { StorageKeyValuePair } from './storage/providers/types';
|
|
@@ -98,45 +98,22 @@ declare function multiGet<TKey extends OnyxKey>(keys: CollectionKeyBase[]): Prom
|
|
|
98
98
|
declare function tupleGet<Keys extends readonly OnyxKey[]>(keys: Keys): Promise<{
|
|
99
99
|
[Index in keyof Keys]: OnyxValue<Keys[Index]>;
|
|
100
100
|
}>;
|
|
101
|
-
/**
|
|
102
|
-
* Stores a subscription ID associated with a given key.
|
|
103
|
-
*
|
|
104
|
-
* @param subscriptionID - A subscription ID of the subscriber.
|
|
105
|
-
* @param key - A key that the subscriber is subscribed to.
|
|
106
|
-
*/
|
|
107
|
-
declare function storeKeyBySubscriptions(key: OnyxKey, subscriptionID: number): void;
|
|
108
|
-
/**
|
|
109
|
-
* Deletes a subscription ID associated with its corresponding key.
|
|
110
|
-
*
|
|
111
|
-
* @param subscriptionID - The subscription ID to be deleted.
|
|
112
|
-
*/
|
|
113
|
-
declare function deleteKeyBySubscriptions(subscriptionID: number): void;
|
|
114
101
|
/** Returns current key names stored in persisted storage */
|
|
115
102
|
declare function getAllKeys(): Promise<Set<OnyxKey>>;
|
|
116
|
-
/**
|
|
117
|
-
* Tries to get a value from the cache. If the value is not present in cache it will return the default value or undefined.
|
|
118
|
-
* If the requested key is a collection, it will return an object with all the collection members.
|
|
119
|
-
*/
|
|
120
|
-
declare function tryGetCachedValue<TKey extends OnyxKey>(key: TKey): OnyxValue<OnyxKey>;
|
|
121
103
|
declare function getCachedCollection<TKey extends CollectionKeyBase>(collectionKey: TKey, collectionMemberKeys?: string[]): NonNullable<OnyxCollection<KeyValueMapping[TKey]>>;
|
|
122
104
|
/**
|
|
123
|
-
*
|
|
124
|
-
|
|
125
|
-
declare function keysChanged<TKey extends CollectionKeyBase>(collectionKey: TKey, partialCollection: OnyxCollection<KeyValueMapping[TKey]>, partialPreviousCollection: OnyxCollection<KeyValueMapping[TKey]> | undefined): void;
|
|
126
|
-
/**
|
|
127
|
-
* When a key change happens, search for any callbacks matching the key or collection key and trigger those callbacks
|
|
105
|
+
* Notify subscribers of a single-key write. Wrapper over `onyxSubscriptionManager.notifyKey()`
|
|
106
|
+
* that also performs LRU bookkeeping for eviction.
|
|
128
107
|
*/
|
|
129
|
-
declare function
|
|
108
|
+
declare function notifyKey<TKey extends OnyxKey>(key: TKey, value: OnyxValue<TKey>): void;
|
|
130
109
|
/**
|
|
131
|
-
*
|
|
110
|
+
* Notify subscribers of a batch collection update. Wrapper over
|
|
111
|
+
* `onyxSubscriptionManager.notifyCollection()` that also performs LRU bookkeeping per
|
|
112
|
+
* changed member.
|
|
132
113
|
*/
|
|
133
|
-
declare function
|
|
114
|
+
declare function notifyCollection<TKey extends CollectionKeyBase>(collectionKey: TKey, partialCollection: OnyxCollection<KeyValueMapping[TKey]>, partialPreviousCollection?: OnyxCollection<KeyValueMapping[TKey]>): void;
|
|
134
115
|
/**
|
|
135
|
-
*
|
|
136
|
-
*/
|
|
137
|
-
declare function getCollectionDataAndSendAsObject<TKey extends OnyxKey>(matchingKeys: CollectionKeyBase[], mapping: CallbackToStateMapping<TKey>): void;
|
|
138
|
-
/**
|
|
139
|
-
* Remove a key from Onyx and update the subscribers
|
|
116
|
+
* Remove a key from Onyx and update the subscribers.
|
|
140
117
|
*/
|
|
141
118
|
declare function remove<TKey extends OnyxKey>(key: TKey): Promise<void>;
|
|
142
119
|
declare function reportStorageQuota(error?: Error): Promise<void>;
|
|
@@ -202,19 +179,6 @@ declare function isValidNonEmptyCollectionForMerge<TKey extends CollectionKeyBas
|
|
|
202
179
|
* Verify if all the collection keys belong to the same parent
|
|
203
180
|
*/
|
|
204
181
|
declare function doAllCollectionItemsBelongToSameParent<TKey extends CollectionKeyBase>(collectionKey: TKey, collectionKeys: string[]): boolean;
|
|
205
|
-
/**
|
|
206
|
-
* Subscribes to an Onyx key and listens to its changes.
|
|
207
|
-
*
|
|
208
|
-
* @param connectOptions The options object that will define the behavior of the connection.
|
|
209
|
-
* @returns The subscription ID to use when calling `OnyxUtils.unsubscribeFromKey()`.
|
|
210
|
-
*/
|
|
211
|
-
declare function subscribeToKey<TKey extends OnyxKey>(connectOptions: ConnectOptions<TKey>): number;
|
|
212
|
-
/**
|
|
213
|
-
* Disconnects and removes the listener from the Onyx key.
|
|
214
|
-
*
|
|
215
|
-
* @param subscriptionID Subscription ID returned by calling `OnyxUtils.subscribeToKey()`.
|
|
216
|
-
*/
|
|
217
|
-
declare function unsubscribeFromKey(subscriptionID: number): void;
|
|
218
182
|
declare function updateSnapshots<TKey extends OnyxKey>(data: Array<OnyxUpdate<TKey>>, mergeFn: typeof Onyx.merge): Array<() => Promise<void>>;
|
|
219
183
|
/**
|
|
220
184
|
* Writes a value to our store with the given key.
|
|
@@ -275,6 +239,10 @@ declare function mergeCollectionWithPatches<TKey extends CollectionKeyBase>({ co
|
|
|
275
239
|
declare function partialSetCollection<TKey extends CollectionKeyBase>({ collectionKey, collection }: SetCollectionParams<TKey>, retryAttempt?: number): Promise<void>;
|
|
276
240
|
declare function logKeyChanged(onyxMethod: Extract<OnyxMethod, 'set' | 'merge'>, key: OnyxKey, value: unknown, hasChanged: boolean): void;
|
|
277
241
|
declare function logKeyRemoved(onyxMethod: Extract<OnyxMethod, 'set' | 'merge'>, key: OnyxKey): void;
|
|
242
|
+
/**
|
|
243
|
+
* Put Onyx back to "not initialised" state, useful for tests that need a cold start.
|
|
244
|
+
*/
|
|
245
|
+
declare function resetDeferredInitTask(): void;
|
|
278
246
|
/**
|
|
279
247
|
* Clear internal variables used in this file, useful in test environments.
|
|
280
248
|
*/
|
|
@@ -288,6 +256,7 @@ declare const OnyxUtils: {
|
|
|
288
256
|
readonly MULTI_SET: "multiset";
|
|
289
257
|
readonly CLEAR: "clear";
|
|
290
258
|
};
|
|
259
|
+
NOT_DELIVERED: symbol;
|
|
291
260
|
getMergeQueue: typeof getMergeQueue;
|
|
292
261
|
getMergeQueuePromise: typeof getMergeQueuePromise;
|
|
293
262
|
getDefaultKeyStates: typeof getDefaultKeyStates;
|
|
@@ -297,12 +266,9 @@ declare const OnyxUtils: {
|
|
|
297
266
|
sendActionToDevTools: typeof sendActionToDevTools;
|
|
298
267
|
get: typeof get;
|
|
299
268
|
getAllKeys: typeof getAllKeys;
|
|
300
|
-
tryGetCachedValue: typeof tryGetCachedValue;
|
|
301
269
|
getCachedCollection: typeof getCachedCollection;
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
sendDataToConnection: typeof sendDataToConnection;
|
|
305
|
-
getCollectionDataAndSendAsObject: typeof getCollectionDataAndSendAsObject;
|
|
270
|
+
notifyKey: typeof notifyKey;
|
|
271
|
+
notifyCollection: typeof notifyCollection;
|
|
306
272
|
remove: typeof remove;
|
|
307
273
|
reportStorageQuota: typeof reportStorageQuota;
|
|
308
274
|
resetDiskPressureLogThrottle: typeof resetDiskPressureLogThrottle;
|
|
@@ -321,14 +287,10 @@ declare const OnyxUtils: {
|
|
|
321
287
|
tupleGet: typeof tupleGet;
|
|
322
288
|
isValidNonEmptyCollectionForMerge: typeof isValidNonEmptyCollectionForMerge;
|
|
323
289
|
doAllCollectionItemsBelongToSameParent: typeof doAllCollectionItemsBelongToSameParent;
|
|
324
|
-
subscribeToKey: typeof subscribeToKey;
|
|
325
|
-
unsubscribeFromKey: typeof unsubscribeFromKey;
|
|
326
290
|
getSkippableCollectionMemberIDs: typeof getSkippableCollectionMemberIDs;
|
|
327
291
|
setSkippableCollectionMemberIDs: typeof setSkippableCollectionMemberIDs;
|
|
328
292
|
getSnapshotMergeKeys: typeof getSnapshotMergeKeys;
|
|
329
293
|
setSnapshotMergeKeys: typeof setSnapshotMergeKeys;
|
|
330
|
-
storeKeyBySubscriptions: typeof storeKeyBySubscriptions;
|
|
331
|
-
deleteKeyBySubscriptions: typeof deleteKeyBySubscriptions;
|
|
332
294
|
reduceCollectionWithSelector: typeof reduceCollectionWithSelector;
|
|
333
295
|
updateSnapshots: typeof updateSnapshots;
|
|
334
296
|
mergeCollectionWithPatches: typeof mergeCollectionWithPatches;
|
|
@@ -341,4 +303,4 @@ declare const OnyxUtils: {
|
|
|
341
303
|
};
|
|
342
304
|
export type { OnyxMethod };
|
|
343
305
|
export default OnyxUtils;
|
|
344
|
-
export { clearOnyxUtilsInternals };
|
|
306
|
+
export { clearOnyxUtilsInternals, resetDeferredInitTask };
|