Add on and un methods to ol.Object

This commit is contained in:
Éric Lemoine
2013-03-29 11:00:29 +01:00
parent dfe30f9feb
commit ce0836e403
2 changed files with 24 additions and 0 deletions

View File

@@ -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.
*/