Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: third_party/polymer/v1_0/components/more-routing/emitter.html

Issue 1269803005: Remove third_party/polymer from .gitignore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2015 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.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
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.txt
8 -->
9 <script>
10 (function(scope) {
11 var MoreRouting = scope.MoreRouting = scope.MoreRouting || {};
12 MoreRouting.Emitter = Object.create(null); // Minimal set of properties.
13
14 /**
15 * A dumb prototype that provides very simple event subscription.
16 *
17 * You are responsible for initializing `__listeners` as an array on objects
18 * that make use of this.
19 */
20 Object.defineProperties(MoreRouting.Emitter, {
21
22 /**
23 * Registers a callback that will be called each time any parameter managed by
24 * this object (or its parents) have changed.
25 *
26 * @param {!Function} callback
27 * @return {{close: function()}}
28 */
29 __subscribe: {
30 value: function __subscribe(callback) {
31 this.__listeners.push(callback);
32
33 return {
34 close: this.__unsubscribe.bind(this, callback),
35 };
36 },
37 },
38
39 /**
40 * Unsubscribes a previously registered callback.
41 *
42 * @param {!Function} callback
43 */
44 __unsubscribe: {
45 value: function __unsubscribe(callback) {
46 var index = this.__listeners.indexOf(callback);
47 if (index < 0) {
48 console.warn(this, 'attempted unsubscribe of unregistered listener:', ca llback);
49 return;
50 }
51 this.__listeners.splice(index, 1);
52 },
53 },
54
55 /**
56 * Notifies subscribed callbacks.
57 */
58 __notify: {
59 value: function __notify(key, value) {
60 if (this.__silent) return;
61 var args = Array.prototype.slice.call(arguments);
62 // Notify listeners on parents first.
63 var parent = Object.getPrototypeOf(this);
64 if (parent && parent.__notify && parent.__listeners) {
65 parent.__notify.apply(parent, args);
66 }
67
68 this.__listeners.forEach(function(listener) {
69 listener.apply(null, args);
70 }.bind(this));
71 },
72 },
73
74 });
75
76 })(window);
77 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698