com.vaadin.polymer.iron.IronLocalstorageElement Maven / Gradle / Ivy
/*
* This code was generated with Vaadin Web Component GWT API Generator,
* from iron-localstorage project by unknown author
* that is licensed with http://polymer.github.io/LICENSE.txt license.
*/
package com.vaadin.polymer.iron;
import com.vaadin.polymer.elemental.*;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
/**
* Element access to Web Storage API (window.localStorage).
* Keeps value
property in sync with localStorage.
* Value is saved as json by default.
* Usage:
* ls-sample
will automatically save changes to its value.
* <dom-module id="ls-sample">
* <iron-localstorage name="my-app-storage"
* value="{{cartoon}}"
* on-iron-localstorage-load-empty="initializeDefaultCartoon"
* ></iron-localstorage>
* </dom-module>
*
* <script>
* Polymer({
* 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);
* }
* });
* </script>
*
*
*
Tech notes:
*
* 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.
*/
@JsType(isNative=true)
public interface IronLocalstorageElement extends HTMLElement {
@JsOverlay public static final String TAG = "iron-localstorage";
@JsOverlay public static final String SRC = "iron-localstorage/iron-localstorage.html";
/**
* Value will not be saved automatically if true. You’ll have to do it manually with save()
*
* JavaScript Info:
* @property autoSaveDisabled
* @type Boolean
*
*/
@JsProperty boolean getAutoSaveDisabled();
/**
* Value will not be saved automatically if true. You’ll have to do it manually with save()
*
* JavaScript Info:
* @property autoSaveDisabled
* @type Boolean
*
*/
@JsProperty void setAutoSaveDisabled(boolean value);
/**
* If true: do not convert value to JSON on save/load
*
* JavaScript Info:
* @property useRaw
* @type Boolean
*
*/
@JsProperty boolean getUseRaw();
/**
* If true: do not convert value to JSON on save/load
*
* JavaScript Info:
* @property useRaw
* @type Boolean
*
*/
@JsProperty void setUseRaw(boolean value);
/**
* The data associated with this storage.
If set to null item will be deleted.
*
* JavaScript Info:
* @property value
* @type *
*
*/
@JsProperty JavaScriptObject getValue();
/**
* The data associated with this storage.
If set to null item will be deleted.
*
* JavaScript Info:
* @property value
* @type *
*
*/
@JsProperty void setValue(JavaScriptObject value);
/**
* Last error encountered while saving/loading items
*
* JavaScript Info:
* @property errorMessage
* @type String
*
*/
@JsProperty String getErrorMessage();
/**
* Last error encountered while saving/loading items
*
* JavaScript Info:
* @property errorMessage
* @type String
*
*/
@JsProperty void setErrorMessage(String value);
/**
* localStorage item key
*
* JavaScript Info:
* @property name
* @type String
*
*/
@JsProperty String getName();
/**
* localStorage item key
*
* JavaScript Info:
* @property name
* @type String
*
*/
@JsProperty void setName(String value);
/**
* Loads the value again. Use if you modify
localStorage using DOM calls, and want to
keep this element in sync.
*
* JavaScript Info:
* @method reload
*
*
*/
void reload();
/**
* Saves the value to localStorage. Call to save if autoSaveDisabled is set.
If value
is null or undefined, deletes localStorage.
*
* JavaScript Info:
* @method save
*
*
*/
void save();
}