EasyManua.ls Logo

Embedded Systems LogiMachine5 Power - Page 52

Embedded Systems LogiMachine5 Power
254 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
52
localStorage wrapper functions
localStorage allows saving client-side configuration. Several functions are provided to safely execute
localStorage functions, as they might fail is some cases like private mode on iOS. It also allows storing
any values that can be serialized using JSON.stringify.
storeSet(key, value) sets key/value pair
storeGet(key) retrieves key value, returns null when key is not found
storeRemove(key) removes key from storage
Storage keys must be prefixed with unique application name to minimize collisions between different
applications
Examples
Get currently selected theme (light/dark)
var theme = storeGet('theme') || 'light';
Store JavaScript objects
var user = { name: 'John', surname: 'Doe', age: 42 };
storeSet('myapp_user', user);

Table of Contents