StateOptions
Options related to Adaptable State hydration / dehydration; allows users to intercept state persistence and loading with custom functionality
All functions deal with AdaptablePersistentState - the persisted subset of AdaptableState.
Transient sections (Internal, Popup, Comment, Plugins) are never passed to, nor expected from, these functions.
Hydration flow: loadState() - (merge with initialState) - applyState()
Dehydration flow: saveState() - persistState()
To store Adaptable State in a custom format (e.g. wrapped in an envelope, compressed, encrypted) do the wrapping in persistState() and the unwrapping in loadState() - these are the only functions which own the storage format.
saveState() and applyState() always operate on Adaptable State, as loadState()'s result is merged with initialState section by section before applyState() is called.
export interfaceProperties
| Property | Type | Description | Default |
|---|---|---|---|
| applyState | AdaptableApplyStateFunction | Transforms state before applying it to the application. Called after loadState() (and after merging with initialState) but before the state is used. | |
| autoMigrateState | boolean | Automatically migrate State from previous AdapTable version to current one | true |
| clearState | AdaptableClearStateFunction | Allows clearing of remote Adaptable State. Only invoked during StateApi.reloadInitialState() operations. | undefined |
| debounceStateDelay | number | Delay (in ms) to debounce saveState / persistState calls enabling grouping multiple sequential calls in single one (e.g. elevator doors)Defaults to: 400. Also, the wait will be max 1000ms, at which point the save/persist calls will happen anyway. | 400 |
| loadState | AdaptableLoadStateFunction | Retrieves saved Adaptable State from storage or external source | |
| persistState | AdaptablePersistStateFunction | Handles the actual storage of state to localStorage, server, etc. Called after saveState() to store the prepared state. | |
| saveState | AdaptableSaveStateFunction | Transforms state before saving to storage. Called before persistState(). |
Property Details
applyState
Transforms state before applying it to the application. Called after loadState() (and after merging with initialState) but before the state is used.
applyState?: AdaptableApplyStateFunction;Property Value
autoMigrateState
Automatically migrate State from previous AdapTable version to current one
autoMigrateState?: boolean;Default Value
true
Property Value
boolean
clearState
Allows clearing of remote Adaptable State. Only invoked during StateApi.reloadInitialState() operations.
clearState?: AdaptableClearStateFunction;Default Value
undefined
Property Value
debounceStateDelay
Delay (in ms) to debounce saveState / persistState calls enabling grouping multiple sequential calls in single one (e.g. elevator doors)
Defaults to: 400. Also, the wait will be max 1000ms, at which point the save/persist calls will happen anyway.
debounceStateDelay?: number;Default Value
400
Property Value
number
loadState
Retrieves saved Adaptable State from storage or external source
loadState?: AdaptableLoadStateFunction;Property Value
persistState
Handles the actual storage of state to localStorage, server, etc. Called after saveState() to store the prepared state.
persistState?: AdaptablePersistStateFunction;Property Value
saveState
Transforms state before saving to storage. Called before persistState().
saveState?: AdaptableSaveStateFunction;