Fix: destroy the old core if needed

This commit is contained in:
Pieter Vander Vennet 2025-02-16 02:03:09 +01:00
parent 9de9f55327
commit 44b094e84b

View file

@ -50,6 +50,7 @@ export default class ThemeSource implements IndexedFeatureSource {
const features = (this.features = new UIEventSource<Feature[]>([]))
const featuresById = (this.featuresById = new UIEventSource(new Map()))
this.core = mvtAvailableLayers.mapD((mvtAvailableLayers) => {
this.core?.data?.destruct()
const core = new ThemeSourceCore(
layers,
featureSwitches,
@ -300,4 +301,9 @@ class ThemeSourceCore extends FeatureSourceMerger {
// await Promise.all(this.supportsForceDownload.map((i) => i.updateAsync()))
console.log("Done")
}
public destruct() {
this.features.destroy()
this.featuresById.destroy()
}
}