Name: iron-localstorage
Owner: PolymerElements
Description: Access to localStorage
Created: 2015-04-27 23:38:21.0
Updated: 2018-04-19 16:52:03.0
Pushed: 2018-05-23 02:30:48.0
Size: 131
Language: HTML
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Element access to Web Storage API (window.localStorage).
Keeps value
property in sync with localStorage.
Value is saved as json by default.
ls-sample
will automatically save changes to its value.
-module id="ls-sample">
ron-localstorage name="my-app-storage"
value="{{cartoon}}"
on-iron-localstorage-load-empty="initializeDefaultCartoon"
/iron-localstorage>
m-module>
ipt>
lymer({
is: 'ls-sample',
properties: {
cartoon: {
type: Object
}
},
// initializes default if nothing has been stored
initializeDefaultCartoon: function() {
this.cartoon = {
name: "Mickey",
hasEars: true
}
},
// use path set api to propagate changes to localstorage
makeModifications: function() {
this.set('cartoon.name', "Minions");
this.set('cartoon.hasEars', false);
}
;
ript>
value.*
is observed, and saved on modifications. You must use
path change notification methods such as set()
to modify value
for changes to be observed.
Set auto-save-disabled
to prevent automatic saving.
Value is saved as JSON by default.
To delete a key, set value to null
Element listens to StorageAPI storage
event, and will reload upon receiving it.
Warning: do not bind value to sub-properties until Polymer
bug 1550
is resolved. Local storage will be blown away.
<iron-localstorage value="{{foo.bar}}"
will cause data loss.