Simplify events and store listeners only in one place

This commit is contained in:
ahocevar
2019-09-04 16:39:32 +02:00
parent d416866108
commit ebfb20440a
52 changed files with 224 additions and 599 deletions

View File

@@ -428,7 +428,7 @@ class VectorSource extends Source {
*/
bindFeaturesCollection_(collection) {
let modifyingCollection = false;
listen(this, VectorEventType.ADDFEATURE,
this.addEventListener(VectorEventType.ADDFEATURE,
/**
* @param {VectorSourceEvent<Geometry>} evt The vector source event
*/
@@ -439,7 +439,7 @@ class VectorSource extends Source {
modifyingCollection = false;
}
});
listen(this, VectorEventType.REMOVEFEATURE,
this.addEventListener(VectorEventType.REMOVEFEATURE,
/**
* @param {VectorSourceEvent<Geometry>} evt The vector source event
*/
@@ -450,7 +450,7 @@ class VectorSource extends Source {
modifyingCollection = false;
}
});
listen(collection, CollectionEventType.ADD,
collection.addEventListener(CollectionEventType.ADD,
/**
* @param {import("../Collection.js").CollectionEvent} evt The collection event
*/
@@ -460,8 +460,8 @@ class VectorSource extends Source {
this.addFeature(/** @type {import("../Feature.js").default<Geometry>} */ (evt.element));
modifyingCollection = false;
}
}, this);
listen(collection, CollectionEventType.REMOVE,
}.bind(this));
collection.addEventListener(CollectionEventType.REMOVE,
/**
* @param {import("../Collection.js").CollectionEvent} evt The collection event
*/
@@ -471,7 +471,7 @@ class VectorSource extends Source {
this.removeFeature(/** @type {import("../Feature.js").default<Geometry>} */ (evt.element));
modifyingCollection = false;
}
}, this);
}.bind(this));
this.featuresCollection_ = collection;
}