You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 2 Next »
SimpleStorage is an object storage. Just like the Map object in JavaScript, it's a collection of key/value, and keys can be of any type.
Methods of this class can be used. For example, in widget client scripts to operate with objects. See the code example below for more clarity.
if (SimpleStorage.hasItem('portalLogo')) { s_widget.setFieldValue("HasLogo", true); s_widget.setFieldValue("logo", SimpleStorage.getItem("portalLogo")); } else { await s_widget.serverUpdate(); SimpleStorage.setItem('portalLogo', s_widget.getFieldValue("logo")); }
Gets a value based on a key.
Return:
Example:
SimpleStorage.getItem('name'); // "Adam"
Checks if there's a key in the storage.
Parameter:
SimpleStorage.hasItem('name'); // true
Sets the value based on a key.
Parameters:
Name
SimpleStorage.setItem('name', 'Adam')
Gets an array of pairs (value, key).
SimpleStorage.getEntries(); // [["name", "Adam"],[ ["secondName", "Smith"]]]
Gets an array of keys.
SimpleStorage.getKeys(); // ["name", "secondName"]
Gets the amount of values stored.
SimpleStorage.getSize(); // 2
Empties the storage.
SimpleStorage.reset();