Appearance
State Store
Pinia store that tracks the application state using object hashing. Emits the
loadwhen a state is loaded and thechangeevent when the data changes.
State
| Name | Description | Type | Values | Default |
|---|---|---|---|---|
| data | current application state | object | - | null |
| history | history of states | array | - | [] |
| historySize | history size | number | - | 25 |
| dataChange | whether the state has changed since last request | boolean | - | false |
| dataChangeTime | last time a data change was recorded | number | - | Date.now() |
Getters
hash
Returns the hash for the current state.
@returnshash
Methods
calcHash
Calculates the hash of the current application state.
@param {Object}data - the data to calculate a hash for@returnshash
checkChanges
Check whether state has changed and set dataChange if so.
@returnsdataChange
on
Registers an event listener for state events.
@param {String}event - event name@param {Function}func - callback@returnshandle for event removal
off
Removes an event listener.
@param {String}event - event name@param {Number}id - event handler id
setData
Update the application state.
@param {object}data@param {boolean}check - whether to check for changes
loadState
Load the application state from state. If callback is not null, it is called with the current state.
@param {object}state
resetDataChange
Sets dataChange to false.
exportState
Exports the current application state (stringified to prevent Vue Proxy effects) and hash.
@param {boolean}reset - whether to reset dataChange@returns{ state: "...", hash: "..." }
clear
Sets data and hash to null and clears the history.