4 Polymer('core-signals',{
9 var i = signals.indexOf(this);
16 // private shared database
20 function notify(name, data) {
21 // convert generic-signal event to named-signal event
22 var signal = new CustomEvent('core-signal-' + name, {
23 // if signals bubble, it's easy to get confusing duplicates
24 // (1) listen on a container on behalf of local child
25 // (2) some deep child ignores the event and it bubbles
26 // up to said container
27 // (3) local child event bubbles up to container
28 // also, for performance, we avoid signals flying up the
29 // tree from all over the place
33 // dispatch named-signal to all 'signals' instances,
34 // only interested listeners will react
35 signals.forEach(function(s) {
36 s.dispatchEvent(signal);
40 // signal listener at document
41 document.addEventListener('core-signal', function(e) {
42 notify(e.detail.name, e.detail.data);