Skip to main content

Type Alias: SyncConfig<State>

SyncConfig<State> = object

Defined in: lib/storage-sync/with-storage-sync.ts:26

Type Parameters​

State​

State

Properties​

autoSync?​

optional autoSync?: boolean

Defined in: lib/storage-sync/with-storage-sync.ts:36

Flag indicating if the store should read from storage on init and write to storage on every state change.

true by default


key​

key: string

Defined in: lib/storage-sync/with-storage-sync.ts:30

The key which is used to access the storage.


parse?​

optional parse?: (stateString) => State

Defined in: lib/storage-sync/with-storage-sync.ts:48

Function used to parse the state coming from storage.

JSON.parse() by default

Parameters​

stateString​

string

Returns​

State


select?​

optional select?: (state) => unknown

Defined in: lib/storage-sync/with-storage-sync.ts:42

Function to select that portion of the state which should be stored.

Returns the whole state object by default

Parameters​

state​

State

Returns​

unknown


storage?​

optional storage?: () => Storage

Defined in: lib/storage-sync/with-storage-sync.ts:62

Returns​

Storage

Deprecated​

Use withSessionStorage instead. Factory function used to switch to sessionStorage.

localStorage by default


stringify?​

optional stringify?: (state) => string

Defined in: lib/storage-sync/with-storage-sync.ts:54

Function used to transform the state into a string representation.

JSON.stringify() by default

Parameters​

state​

State

Returns​

string