attemp at handling data not ready in state
This commit is contained in:
+6
-4
@@ -20,10 +20,6 @@ export const useMresoStore = defineStore("mresoStore", {
|
||||
$fetch<FeatureCollection<Point>>("/clusters.json", options),
|
||||
$fetch<FeatureCollection<Point>>("/stops.json", options),
|
||||
]);
|
||||
|
||||
this.lines = await $fetch("/lines.json", options);
|
||||
this.clusters = await $fetch("/clusters.json", options);
|
||||
this.stops = await $fetch("/stops.json", options);
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
@@ -31,11 +27,17 @@ export const useMresoStore = defineStore("mresoStore", {
|
||||
return Object.fromEntries(state.routes.map((r) => [r.id, r]));
|
||||
},
|
||||
linesById(state): { [id: string]: Feature<MultiLineString> } {
|
||||
if (!state.lines) {
|
||||
return {};
|
||||
}
|
||||
return Object.fromEntries(
|
||||
state.lines.features.map((l) => [l.properties!.id, l]),
|
||||
);
|
||||
},
|
||||
clustersById(state): { [id: string]: Feature<Point> } {
|
||||
if (!state.clusters) {
|
||||
return {};
|
||||
}
|
||||
return Object.fromEntries(
|
||||
state.clusters.features.map((l) => [l.properties!.id, l]),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user