OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE | 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE |
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS | 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS |
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS | 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS |
6 Code distributed by Google as part of the polymer project is also | 6 Code distributed by Google as part of the polymer project is also |
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS | 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS |
8 --> | 8 --> |
9 <link rel="import" href="../polymer/polymer.html"> | 9 <link rel="import" href="../polymer/polymer.html"> |
10 | 10 |
11 <!-- | 11 <!-- |
12 `core-signals` provides basic publish-subscribe functionality. | 12 `core-signals` provides basic publish-subscribe functionality. |
13 | 13 |
14 Note: avoid using `core-signals` whenever you can use | 14 Note: avoid using `core-signals` whenever you can use |
15 a controller (parent element) to mediate communication | 15 a controller (parent element) to mediate communication |
16 instead. | 16 instead. |
17 | 17 |
18 To send a signal, fire a custom event of type `core-signal`, with | 18 To send a signal, fire a custom event of type `core-signal`, with |
19 a detail object containing `name` and `data` fields. | 19 a detail object containing `name` and `data` fields. |
20 | 20 |
21 this.fire('core-signal', {name: 'hello', data: null}); | 21 this.fire('core-signal', {name: 'hello', data: null}); |
22 | 22 |
23 To receive a signal, listen for `core-signal-<name>` event on a | 23 To receive a signal, listen for `core-signal-<name>` event on a |
24 `core-signal` element. | 24 `core-signals` element. |
25 | 25 |
26 <core-signal on-core-signal-hello="{{helloSignal}}"> | 26 <core-signals on-core-signal-hello="{{helloSignal}}"> |
27 | 27 |
28 You can fire a signal event from anywhere, and all | 28 You can fire a signal event from anywhere, and all |
29 `core-signal` elements will receive the event, regardless | 29 `core-signals` elements will receive the event, regardless |
30 of where they are in DOM. | 30 of where they are in DOM. |
31 | 31 |
32 @group Polymer Core Elements | 32 @group Polymer Core Elements |
33 @element core-signals | 33 @element core-signals |
34 @status stable | 34 @status stable |
35 @homepage github.io | 35 @homepage github.io |
36 --> | 36 --> |
37 <polymer-element name="core-signals"> | 37 <polymer-element name="core-signals"> |
38 <script> | 38 <script> |
39 (function(){ | 39 (function(){ |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 // signal listener at document | 77 // signal listener at document |
78 document.addEventListener('core-signal', function(e) { | 78 document.addEventListener('core-signal', function(e) { |
79 notify(e.detail.name, e.detail.data); | 79 notify(e.detail.name, e.detail.data); |
80 }); | 80 }); |
81 | 81 |
82 })(); | 82 })(); |
83 </script> | 83 </script> |
84 </polymer-element> | 84 </polymer-element> |
OLD | NEW |