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
+4 -5
View File
@@ -91,24 +91,23 @@ function renderCircleGeometry(builderGroup, geometry, style, feature) {
* @param {import("../Feature.js").FeatureLike} feature Feature.
* @param {import("../style/Style.js").default} style Style.
* @param {number} squaredTolerance Squared tolerance.
* @param {function(this: T, import("../events/Event.js").default): void} listener Listener function.
* @param {T} thisArg Value to use as `this` when executing `listener`.
* @param {function(import("../events/Event.js").default): void} listener Listener function.
* @return {boolean} `true` if style is loading.
* @template T
*/
export function renderFeature(replayGroup, feature, style, squaredTolerance, listener, thisArg) {
export function renderFeature(replayGroup, feature, style, squaredTolerance, listener) {
let loading = false;
const imageStyle = style.getImage();
if (imageStyle) {
let imageState = imageStyle.getImageState();
if (imageState == ImageState.LOADED || imageState == ImageState.ERROR) {
imageStyle.unlistenImageChange(listener, thisArg);
imageStyle.unlistenImageChange(listener);
} else {
if (imageState == ImageState.IDLE) {
imageStyle.load();
}
imageState = imageStyle.getImageState();
imageStyle.listenImageChange(listener, thisArg);
imageStyle.listenImageChange(listener);
loading = true;
}
}