2021-04-18 14:24:30 +02:00
|
|
|
import FeatureSource from "./FeatureSource";
|
|
|
|
import {UIEventSource} from "../UIEventSource";
|
|
|
|
import State from "../../State";
|
|
|
|
|
|
|
|
export default class RegisteringFeatureSource implements FeatureSource {
|
2021-04-23 12:55:38 +02:00
|
|
|
public readonly features: UIEventSource<{ feature: any; freshness: Date }[]>;
|
|
|
|
public readonly name;
|
2021-04-18 14:24:30 +02:00
|
|
|
constructor(source: FeatureSource) {
|
|
|
|
this.features = source.features;
|
2021-04-23 12:55:38 +02:00
|
|
|
this.name = "RegisteringSource of "+source.name;
|
2021-04-18 14:24:30 +02:00
|
|
|
this.features.addCallbackAndRun(features => {
|
|
|
|
for (const feature of features ?? []) {
|
|
|
|
if (!State.state.allElements.has(feature.feature.properties.id)) {
|
|
|
|
State.state.allElements.addOrGetElement(feature.feature)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|