You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/storage/README.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,8 @@ type PersistedOptions<Type, StorageOptions> = {
40
40
deserialize?: (value:string) =>Type(value),
41
41
// sync API (see below)
42
42
sync?:PersistenceSyncAPI
43
+
// isHydrated from @solid-primitives/lifecycle
44
+
isHydrated?: () =>boolean
43
45
};
44
46
```
45
47
@@ -48,8 +50,8 @@ type PersistedOptions<Type, StorageOptions> = {
48
50
- initial values of signals or stores are not persisted, so they can be safely changed
49
51
- values persisted in asynchronous storage APIs will not overwrite already changed signals or stores
50
52
- setting a persisted signal to undefined or null will remove the item from the storage
51
-
- to use `makePersisted` with other state management APIs, you need some adapter that will project your API to either
52
-
the output of `createSignal` or `createStore`
53
+
- to use `makePersisted` with other state management APIs, you need some adapter that will project your API to either the output of `createSignal` or `createStore`
54
+
- if you experience hydration mismatch issues, add `isHydrated` from the [lifecycles package](../lifecycle/) to your options to delay the initialization until the parent component is hydrated
/** The name of the item in storage, `createUniqueId` is used to generate it otherwise, which means that it is bound to the component scope then */
62
63
name?: string;
64
+
/** A function that turns the value into a string for the storage. `JSON.stringify` is used as default. You can use seroval or your own custom serializer. */
63
65
serialize?: (data: T)=>string;
66
+
/** A function that turns the string from the storage back into the value. `JSON.parse` is used as default. You can use seroval or your own custom deserializer. */
64
67
deserialize?: (data: string)=>T;
68
+
/** Add one of the existing Sync APIs to sync storages over boundaries or provide your own */
65
69
sync?: PersistenceSyncAPI;
70
+
/** If you experience hydration mismatch issues, add `isHydrated` from `@solid-primitives/lifecycle` here */
71
+
isHydrated?: ()=>boolean;
66
72
}&(undefinedextendsO
67
73
? {storage?: SyncStorage|AsyncStorage}
68
74
: {
@@ -77,9 +83,9 @@ export type SignalType<S extends SignalInput> =
0 commit comments