~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/www/bower_components/iron-localstorage/README.md

  • Committer: Didier Roche
  • Date: 2016-05-10 23:09:11 UTC
  • Revision ID: didier.roche@canonical.com-20160510230911-c7xr490zrj3yrzxd
New version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
<!---
 
3
 
 
4
This README is automatically generated from the comments in these files:
 
5
iron-localstorage.html
 
6
 
 
7
Edit those files, and our readme bot will duplicate them over here!
 
8
Edit this file, and the bot will squash your changes :)
 
9
 
 
10
-->
 
11
 
 
12
[![Build Status](https://travis-ci.org/PolymerElements/iron-localstorage.svg?branch=master)](https://travis-ci.org/PolymerElements/iron-localstorage)
 
13
 
 
14
_[Demo and API Docs](https://elements.polymer-project.org/elements/iron-localstorage)_
 
15
 
 
16
 
 
17
##&lt;iron-localstorage&gt;
 
18
 
 
19
 
 
20
Element access to Web Storage API (window.localStorage).
 
21
 
 
22
Keeps `value` property in sync with localStorage.
 
23
 
 
24
Value is saved as json by default.
 
25
 
 
26
### Usage:
 
27
 
 
28
`ls-sample` will automatically save changes to its value.
 
29
 
 
30
    <dom-module id="ls-sample">
 
31
      <iron-localstorage name="my-app-storage"
 
32
        value="{{cartoon}}"
 
33
        on-iron-localstorage-load-empty="initializeDefaultCartoon"
 
34
      ></iron-localstorage>
 
35
    </dom-module>
 
36
 
 
37
    <script>
 
38
      Polymer({
 
39
        is: 'ls-sample',
 
40
        properties: {
 
41
          cartoon: {
 
42
            type: Object
 
43
          }
 
44
        },
 
45
        // initializes default if nothing has been stored
 
46
        initializeDefaultCartoon: function() {
 
47
          this.cartoon = {
 
48
            name: "Mickey",
 
49
            hasEars: true
 
50
          }
 
51
        },
 
52
        // use path set api to propagate changes to localstorage
 
53
        makeModifications: function() {
 
54
          this.set('cartoon.name', "Minions");
 
55
          this.set('cartoon.hasEars', false);
 
56
        }
 
57
      });
 
58
    </script>
 
59
 
 
60
### Tech notes:
 
61
 
 
62
* `value.*` is observed, and saved on modifications. You must use
 
63
    path change notifification methods such as `set()` to modify value
 
64
    for changes to be observed.
 
65
 
 
66
* Set `auto-save-disabled` to prevent automatic saving.
 
67
 
 
68
* Value is saved as JSON by default.
 
69
 
 
70
* To delete a key, set value to null
 
71
 
 
72
Element listens to StorageAPI `storage` event, and will reload upon receiving it.
 
73
 
 
74
**Warning**: do not bind value to sub-properties until Polymer
 
75
[bug 1550](https://github.com/Polymer/polymer/issues/1550)
 
76
is resolved. Local storage will be blown away.
 
77
`<iron-localstorage value="{{foo.bar}}"` will cause **data loss**.
 
78
 
 
79