react-native-onyx 3.0.112 → 3.0.113
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 +13 -0
- package/README.md +4 -0
- package/dist/Onyx.d.ts +8 -1
- package/dist/Onyx.js +18 -0
- package/package.json +1 -1
package/API.md
CHANGED
|
@@ -58,6 +58,11 @@ value will be saved to storage after the default value.</p>
|
|
|
58
58
|
<dd><p>Sets a collection by replacing all existing collection members with new values.
|
|
59
59
|
Any existing collection members not included in the new data will be removed.</p>
|
|
60
60
|
</dd>
|
|
61
|
+
<dt><a href="#exportState">exportState()</a></dt>
|
|
62
|
+
<dd><p>Returns persisted Onyx key-value pairs as a plain object.
|
|
63
|
+
Live RAM-only values and writes that have not reached storage are not included.
|
|
64
|
+
Treat the returned object and its nested values as read-only.</p>
|
|
65
|
+
</dd>
|
|
61
66
|
</dl>
|
|
62
67
|
|
|
63
68
|
<a name="init"></a>
|
|
@@ -257,3 +262,11 @@ Onyx.setCollection(ONYXKEYS.COLLECTION.REPORT, {
|
|
|
257
262
|
[`${ONYXKEYS.COLLECTION.REPORT}2`]: report2,
|
|
258
263
|
});
|
|
259
264
|
```
|
|
265
|
+
<a name="exportState"></a>
|
|
266
|
+
|
|
267
|
+
## exportState()
|
|
268
|
+
Returns persisted Onyx key-value pairs as a plain object.
|
|
269
|
+
Live RAM-only values and writes that have not reached storage are not included.
|
|
270
|
+
Treat the returned object and its nested values as read-only.
|
|
271
|
+
|
|
272
|
+
**Kind**: global function
|
package/README.md
CHANGED
|
@@ -288,6 +288,10 @@ function signOut() {
|
|
|
288
288
|
}
|
|
289
289
|
```
|
|
290
290
|
|
|
291
|
+
## Export persisted state
|
|
292
|
+
|
|
293
|
+
`Onyx.exportState()` returns a plain object containing persisted keys and values from the active storage provider. It works on native and web without opening another database connection. The export excludes stale persisted rows for keys that are now RAM-only. Current RAM-only values and writes still in progress are never included. Treat the returned object and its nested values as read-only because some providers return references to their stored values. The result can contain sensitive data; callers should redact it before sharing.
|
|
294
|
+
|
|
291
295
|
## Storage Providers
|
|
292
296
|
`Onyx.get`, `Onyx.set`, and the rest of the API accesses the underlying storage
|
|
293
297
|
differently depending on the platform
|
package/dist/Onyx.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Logger from './Logger';
|
|
2
|
-
import type { CollectionKeyBase, ConnectOptions, InitOptions, OnyxKey, OnyxMergeCollectionInput, OnyxMergeInput, OnyxMultiSetInput, OnyxSetCollectionInput, OnyxSetInput, OnyxUpdate, SetOptions } from './types';
|
|
2
|
+
import type { CollectionKeyBase, ConnectOptions, InitOptions, OnyxKey, OnyxMergeCollectionInput, OnyxMergeInput, OnyxMultiSetInput, OnyxSetCollectionInput, OnyxSetInput, OnyxUpdate, OnyxValue, SetOptions } from './types';
|
|
3
3
|
import type { Connection } from './OnyxConnectionManager';
|
|
4
4
|
/** Initialize the store with actions and listening for storage events */
|
|
5
5
|
declare function init({ keys, initialKeyStates, evictableKeys, shouldSyncMultipleInstances, enableDevTools, skippableCollectionMemberIDs, ramOnlyKeys, snapshotMergeKeys, }: InitOptions): void;
|
|
@@ -152,6 +152,12 @@ declare function update<TKey extends OnyxKey>(data: Array<OnyxUpdate<TKey>>): Pr
|
|
|
152
152
|
* @param collection Object collection keyed by individual collection member keys and values
|
|
153
153
|
*/
|
|
154
154
|
declare function setCollection<TKey extends CollectionKeyBase>(collectionKey: TKey, collection: OnyxSetCollectionInput<TKey>): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* Returns persisted Onyx key-value pairs as a plain object.
|
|
157
|
+
* Live RAM-only values and writes that have not reached storage are not included.
|
|
158
|
+
* Treat the returned object and its nested values as read-only.
|
|
159
|
+
*/
|
|
160
|
+
declare function exportState(): Promise<Record<OnyxKey, OnyxValue<OnyxKey>>>;
|
|
155
161
|
declare const Onyx: {
|
|
156
162
|
METHOD: {
|
|
157
163
|
readonly SET: "set";
|
|
@@ -171,6 +177,7 @@ declare const Onyx: {
|
|
|
171
177
|
setCollection: typeof setCollection;
|
|
172
178
|
update: typeof update;
|
|
173
179
|
clear: typeof clear;
|
|
180
|
+
exportState: typeof exportState;
|
|
174
181
|
init: typeof init;
|
|
175
182
|
registerLogger: typeof Logger.registerLogger;
|
|
176
183
|
};
|
package/dist/Onyx.js
CHANGED
|
@@ -554,6 +554,23 @@ function update(data) {
|
|
|
554
554
|
function setCollection(collectionKey, collection) {
|
|
555
555
|
return OnyxUtils_1.default.afterInit(() => OnyxUtils_1.default.setCollectionWithRetry({ collectionKey, collection }));
|
|
556
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* Returns persisted Onyx key-value pairs as a plain object.
|
|
559
|
+
* Live RAM-only values and writes that have not reached storage are not included.
|
|
560
|
+
* Treat the returned object and its nested values as read-only.
|
|
561
|
+
*/
|
|
562
|
+
function exportState() {
|
|
563
|
+
return OnyxUtils_1.default.afterInit(() => storage_1.default.getAll().then((entries) => {
|
|
564
|
+
const state = {};
|
|
565
|
+
for (const [key, value] of entries) {
|
|
566
|
+
if (OnyxKeys_1.default.isRamOnlyKey(key)) {
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
state[key] = value;
|
|
570
|
+
}
|
|
571
|
+
return state;
|
|
572
|
+
}));
|
|
573
|
+
}
|
|
557
574
|
const Onyx = {
|
|
558
575
|
METHOD: OnyxUtils_1.default.METHOD,
|
|
559
576
|
connect,
|
|
@@ -566,6 +583,7 @@ const Onyx = {
|
|
|
566
583
|
setCollection,
|
|
567
584
|
update,
|
|
568
585
|
clear,
|
|
586
|
+
exportState,
|
|
569
587
|
init,
|
|
570
588
|
registerLogger: Logger.registerLogger,
|
|
571
589
|
};
|