From ce0836e403d10293b8671770b09c0639b3f570d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Fri, 29 Mar 2013 11:00:29 +0100 Subject: [PATCH] Add on and un methods to ol.Object --- src/ol/object.exports | 2 ++ src/ol/object.js | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/ol/object.exports b/src/ol/object.exports index 98c8370bdb..4e9f162546 100644 --- a/src/ol/object.exports +++ b/src/ol/object.exports @@ -3,8 +3,10 @@ @exportProperty ol.Object.prototype.changed @exportProperty ol.Object.prototype.get @exportProperty ol.Object.prototype.notify +@exportProperty ol.Object.prototype.on @exportProperty ol.Object.prototype.set @exportProperty ol.Object.prototype.setOptions @exportProperty ol.Object.prototype.setValues +@exportProperty ol.Object.prototype.un @exportProperty ol.Object.prototype.unbind @exportProperty ol.Object.prototype.unbindAll diff --git a/src/ol/object.js b/src/ol/object.js index 861eb651ad..5f9111881f 100644 --- a/src/ol/object.js +++ b/src/ol/object.js @@ -229,6 +229,17 @@ ol.Object.prototype.notifyInternal_ = function(key) { }; +/** + * @param {string} type The event type. + * @param {Function} listener The listener function. + * @param {Object=} opt_scope Object is whose scope to call + * the listener. + */ +ol.Object.prototype.on = function(type, listener, opt_scope) { + goog.events.listen(this, type, listener, false, opt_scope); +}; + + /** * @param {string} key Key. * @param {*} value Value. @@ -292,6 +303,17 @@ ol.Object.prototype.unbind = function(key) { }; +/** + * @param {string} type The event type. + * @param {Function} listener The listener function. + * @param {Object=} opt_scope Object is whose scope to call + * the listener. + */ +ol.Object.prototype.un = function(type, listener, opt_scope) { + goog.events.unlisten(this, type, listener, false, opt_scope); +}; + + /** * Removes all bindings. */