Index: third_party/polymer/v0_8/components/polymer/src/micro/debouncer.html |
diff --git a/third_party/polymer/v0_8/components/polymer/src/micro/debouncer.html b/third_party/polymer/v0_8/components/polymer/src/micro/debouncer.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7afbfce5e1e556105b8de51e4600b0117fb47320 |
--- /dev/null |
+++ b/third_party/polymer/v0_8/components/polymer/src/micro/debouncer.html |
@@ -0,0 +1,57 @@ |
+<!-- |
+@license |
+Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
+This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt |
+The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
+The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt |
+Code distributed by Google as part of the polymer project is also |
+subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
+--> |
+<script> |
+ |
+ Polymer.Base._addFeature({ |
+ |
+ _setupDebouncers: function() { |
+ this._debouncers = {}; |
+ }, |
+ |
+ /** |
+ * Debounce signals. |
+ * |
+ * Call `debounce` to collapse multiple requests for a named task into |
+ * one invocation which is made after the wait time has elapsed with |
+ * no new request. |
+ * |
+ * debouncedClickAction: function(e) { |
+ * // will not call `processClick` more than once per 100ms |
+ * this.debounce('click', function() { |
+ * this.processClick; |
+ * }, 100); |
+ * } |
+ * |
+ * @method debounce |
+ * @param String {String} jobName A string to indentify the debounce job. |
+ * @param Function {Function} callback A function that is called (with `this` context) when the wait time elapses. |
+ * @param Number {Number} wait Time in milliseconds (ms) after the last signal that must elapse before invoking `callback` |
+ * @type Handle |
+ */ |
+ debounce: function(jobName, callback, wait) { |
+ this._debouncers[jobName] = Polymer.Debounce.call(this, |
+ this._debouncers[jobName], callback, wait); |
+ }, |
+ |
+ isDebouncerActive: function(jobName) { |
+ var debouncer = this._debouncers[jobName]; |
+ return debouncer && debouncer.finish; |
+ }, |
+ |
+ flushDebouncer: function(jobName) { |
+ var debouncer = this._debouncers[jobName]; |
+ if (debouncer) { |
+ debouncer.complete(); |
+ } |
+ } |
+ |
+ }); |
+ |
+</script> |