generated from bcgov/vue3-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreactor.js
More file actions
41 lines (38 loc) · 1.16 KB
/
reactor.js
File metadata and controls
41 lines (38 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { reactive } from "vue";
import {
getAllWatershedLicences,
getWaterPortalStations
} from "@/utils/api.js";
// acts as a data store which will store data while across routing actions etc.
export const portalHandler = reactive({
viewType: '',
updateViewType: (viewType) => {
portalHandler.viewType = viewType;
}
});
export const fetchCache = reactive({
watershedPoints: null,
groundwaterPoints: null,
groundwaterCaptureZones: null,
groundwaterAquifers: null,
waterPortal: {
streams: null,
surface: null,
ground: null,
wells: null,
weather: null,
},
// fetchers to check if data already exists, otherwise fetch it
fetchWatershedLicences: async () => {
if(!fetchCache.watershedPoints){
fetchCache.watershedPoints = await getAllWatershedLicences();
}
return fetchCache.watershedPoints;
},
fetchWaterPortalPoints: async (viewType) => {
if(!fetchCache.waterPortal[viewType]){
fetchCache.waterPortal[viewType] = await getWaterPortalStations(viewType);
}
return fetchCache.waterPortal[viewType];
}
});