pixso.clientStorage
The pixso.clientStorage
API allows plugins to store data locally to the user. Unlike document data storage (e.g. setPluginData
), this data is not synchronized across users. It is similar to the Window.localStorage
API, but it is asynchronous and allows storage of objects, arrays, strings, numbers, booleans, null, undefined and Uint8Array. as with Window.localStorage
, user actions such as clearing the browser cache may clear all stored data.
The data stored in pixso.clientStorage
is distinguished by the plugin Id, so the current plugin cannot read the data stored by other plugins, and if you need to share data across plugins, you can use the setSharedPluginData
API.
The pixso.clientStorage
API has four methods: getAsync
, setAsync
, deleteAsync
, and keysAsync
.
getAsync
- Type:
getAsync(key: string): Promise<any | undefined>
Retrieves a value from client storage with the given key
. If no value has been stored for that key, this function will asynchronously return undefined
.
setAsync
- Type:
setAsync(key: string, value: any): Promise<void>
Sets a value to client storage with the given key
. The returned promise will resolve if storage is successful, or reject with an error message if storage failed.
deleteAsync
- Type:
deleteAsync(key: string): Promise<void>
Removes the stored key/value pair from client storage with the given key
. If no such key
is stored, this function will return normally but will otherwise do nothing.
keysAsync
- Type:
keysAsync(): Promise<string[]>
Retrieves a list of all keys stored to client storage. Use this to enumerate the full contents of the clientStorage
API.