maplibre-gl-layer-control 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +8 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ class CustomLayerRegistry {
|
|
|
7
7
|
constructor() {
|
|
8
8
|
__publicField(this, "adapters", /* @__PURE__ */ new Map());
|
|
9
9
|
__publicField(this, "changeListeners", []);
|
|
10
|
-
__publicField(this, "unsubscribers",
|
|
10
|
+
__publicField(this, "unsubscribers", /* @__PURE__ */ new Map());
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Register a custom layer adapter.
|
|
@@ -19,7 +19,7 @@ class CustomLayerRegistry {
|
|
|
19
19
|
const unsubscribe = adapter.onLayerChange((event, layerId) => {
|
|
20
20
|
this.notifyChange(event, layerId);
|
|
21
21
|
});
|
|
22
|
-
this.unsubscribers.
|
|
22
|
+
this.unsubscribers.set(adapter.type, unsubscribe);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
@@ -27,6 +27,11 @@ class CustomLayerRegistry {
|
|
|
27
27
|
* @param type The adapter type to unregister
|
|
28
28
|
*/
|
|
29
29
|
unregister(type) {
|
|
30
|
+
const unsubscribe = this.unsubscribers.get(type);
|
|
31
|
+
if (unsubscribe) {
|
|
32
|
+
unsubscribe();
|
|
33
|
+
this.unsubscribers.delete(type);
|
|
34
|
+
}
|
|
30
35
|
this.adapters.delete(type);
|
|
31
36
|
}
|
|
32
37
|
/**
|
|
@@ -137,7 +142,7 @@ class CustomLayerRegistry {
|
|
|
137
142
|
*/
|
|
138
143
|
destroy() {
|
|
139
144
|
this.unsubscribers.forEach((unsub) => unsub());
|
|
140
|
-
this.unsubscribers
|
|
145
|
+
this.unsubscribers.clear();
|
|
141
146
|
this.adapters.clear();
|
|
142
147
|
this.changeListeners = [];
|
|
143
148
|
}
|