Merge pull request #2794 from elemoine/unbykey

Add ol.Observable.unByKey
This commit is contained in:
Éric Lemoine
2014-10-08 15:14:12 +02:00
2 changed files with 17 additions and 6 deletions

View File

@@ -34,6 +34,16 @@ ol.Observable = function() {
goog.inherits(ol.Observable, goog.events.EventTarget);
/**
* Removes an event listener using the key returned by `on()` or `once()`.
* @param {goog.events.Key} key The key returned by `on()` or `once()`.
* @api stable
*/
ol.Observable.unByKey = function(key) {
goog.events.unlistenByKey(key);
};
/**
* Increases the revision counter and disptches a 'change' event.
* @fires change
@@ -95,9 +105,10 @@ ol.Observable.prototype.un = function(type, listener, opt_this) {
/**
* Removes an event listener using the key returned by `on()` or `once()`.
* @param {goog.events.Key} key Key.
* Note that using the {@link ol.Observable.unByKey} static function is to
* be preferred.
* @param {goog.events.Key} key The key returned by `on()` or `once()`.
* @function
* @api stable
*/
ol.Observable.prototype.unByKey = function(key) {
goog.events.unlistenByKey(key);
};
ol.Observable.prototype.unByKey = ol.Observable.unByKey;