forked from MapComplete/MapComplete
Chore: use strict on two classes
This commit is contained in:
parent
fe0929ef6f
commit
de782d7356
2 changed files with 41 additions and 15 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import { FeatureSource } from "../FeatureSource"
|
||||
import { ImmutableStore, Store } from "../../UIEventSource"
|
||||
import { FeatureSource, WritableFeatureSource } from "../FeatureSource"
|
||||
import { ImmutableStore, Store, UIEventSource } from "../../UIEventSource"
|
||||
import { Feature } from "geojson"
|
||||
|
||||
"use strict"
|
||||
/**
|
||||
* A simple, read only feature store.
|
||||
*/
|
||||
|
|
@ -30,3 +31,28 @@ export default class StaticFeatureSource<T extends Feature = Feature> implements
|
|||
return new StaticFeatureSource(geojson)
|
||||
}
|
||||
}
|
||||
|
||||
export class WritableStaticFeatureSource<T extends Feature = Feature> implements WritableFeatureSource<T> {
|
||||
public readonly features: UIEventSource<T[]> = undefined
|
||||
|
||||
constructor(features: UIEventSource<T[]> | T[] | { features: T[] } | { features: Store<T[]> }) {
|
||||
if (features === undefined) {
|
||||
throw "Static feature source received undefined as source"
|
||||
}
|
||||
|
||||
let feats: T[] | UIEventSource<T[]>
|
||||
|
||||
if (features["features"]) {
|
||||
feats = features["features"]
|
||||
} else {
|
||||
feats = <T[] | UIEventSource<T[]>>features
|
||||
}
|
||||
|
||||
if (Array.isArray(feats)) {
|
||||
this.features = new UIEventSource<T[]>(feats)
|
||||
} else {
|
||||
this.features = feats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue