Blame view

bower_components/iron-localstorage/README.md 2.12 KB
73bcce88   luigser   COMPONENTS
1
  
a1a3bc73   Luigi Serra   graphs updates
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  <!---
  
  This README is automatically generated from the comments in these files:
  iron-localstorage.html
  
  Edit those files, and our readme bot will duplicate them over here!
  Edit this file, and the bot will squash your changes :)
  
  -->
  
  [![Build Status](https://travis-ci.org/PolymerElements/iron-localstorage.svg?branch=master)](https://travis-ci.org/PolymerElements/iron-localstorage)
  
  _[Demo and API Docs](https://elements.polymer-project.org/elements/iron-localstorage)_
  
  
  ##&lt;iron-localstorage&gt;
  
  
  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 notifification 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](https://github.com/Polymer/polymer/issues/1550)
  is resolved. Local storage will be blown away.
  `<iron-localstorage value="{{foo.bar}}"` will cause **data loss**.
73bcce88   luigser   COMPONENTS

73bcce88   luigser   COMPONENTS