MapComplete/Logic/FeatureSource/Actors/RegisteringAllFromFeatureSourceActor.ts

22 lines
789 B
TypeScript
Raw Normal View History

import FeatureSource from "../FeatureSource";
import {Store} from "../../UIEventSource";
import {ElementStorage} from "../../ElementStorage";
2021-04-18 14:24:30 +02:00
/**
* Makes sure that every feature is added to the ElementsStorage, so that the tags-eventsource can be retrieved
*/
export default class RegisteringAllFromFeatureSourceActor {
public readonly features: Store<{ feature: any; freshness: Date }[]>;
public readonly name;
constructor(source: FeatureSource, allElements: ElementStorage) {
2021-04-18 14:24:30 +02:00
this.features = source.features;
this.name = "RegisteringSource of " + source.name;
2021-06-30 16:02:46 +02:00
this.features.addCallbackAndRunD(features => {
for (const feature of features) {
allElements.addOrGetElement(feature.feature)
2021-04-18 14:24:30 +02:00
}
})
}
}