DefineStoreOptions
Properties
Section titled “Properties”migrate?
Section titled “migrate?”optional migrate?: (state, from) => Record<string, unknown>;Bring persisted state written at an older persistVersion up to the current one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
state | Record<string, unknown> |
from | number |
Returns
Section titled “Returns”Record<string, unknown>
onRestoreError?
Section titled “onRestoreError?”optional onRestoreError?: (error) => void;Called when persisted state is refused instead of restored. Defaults to a development warning.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
error | RestoreError |
Returns
Section titled “Returns”void
persist?
Section titled “persist?”optional persist?: PersistAdapter;Restore this store from disk on first use, and write it back as it changes.
persistDebounceMs?
Section titled “persistDebounceMs?”optional persistDebounceMs?: number;Coalesce disk writes for this long. Default 100.
persistKeys?
Section titled “persistKeys?”optional persistKeys?: string[];Persist only these keys. Default: every key that has been written.
persistVersion?
Section titled “persistVersion?”optional persistVersion?: number;The version of your persisted state’s shape. Bump it whenever a key changes
meaning or type, and supply migrate to carry old data forward. Default 0,
which is also what anything written before this existed reads as.
scope?
Section titled “scope?”optional scope?: ShareScope;How far this store is shared. Default ‘everywhere’.