reactjrx 1.89.0 → 1.90.0
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IDENTIFIER_PERSISTANCE_KEY } from './constants';
|
|
2
|
+
import { Signal } from '../signal';
|
|
2
3
|
|
|
3
4
|
export interface Adapter {
|
|
4
5
|
getItem: (key: string) => Promise<unknown>;
|
|
@@ -11,3 +12,14 @@ export interface PersistanceEntry {
|
|
|
11
12
|
migrationVersion?: number;
|
|
12
13
|
[IDENTIFIER_PERSISTANCE_KEY]: typeof IDENTIFIER_PERSISTANCE_KEY;
|
|
13
14
|
}
|
|
15
|
+
export interface SignalPersistenceConfig<Value> {
|
|
16
|
+
version: number;
|
|
17
|
+
signal: Signal<any, Value, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Only called if there is a value to hydrate
|
|
20
|
+
*/
|
|
21
|
+
hydrate?: (params: {
|
|
22
|
+
version: number;
|
|
23
|
+
value: Value;
|
|
24
|
+
}) => Value;
|
|
25
|
+
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Adapter } from './types';
|
|
1
|
+
import { Adapter, SignalPersistenceConfig } from './types';
|
|
3
2
|
|
|
4
|
-
export declare
|
|
5
|
-
entries?:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
onReady?: (
|
|
3
|
+
export declare function usePersistSignals({ entries, onReady, adapter }: {
|
|
4
|
+
entries?: Array<SignalPersistenceConfig<any>>;
|
|
5
|
+
/**
|
|
6
|
+
* Triggered after first successful hydrate
|
|
7
|
+
*/
|
|
8
|
+
onReady?: () => void;
|
|
10
9
|
/**
|
|
11
10
|
* Requires a stable instance otherwise the hydration
|
|
12
11
|
* process will start again. This is useful when you
|
|
13
12
|
* need to change adapter during runtime.
|
|
14
13
|
*/
|
|
15
|
-
adapter
|
|
16
|
-
})
|
|
14
|
+
adapter: Adapter;
|
|
15
|
+
}): {
|
|
17
16
|
isHydrated: boolean;
|
|
18
17
|
};
|