16 lines
566 B
TypeScript
16 lines
566 B
TypeScript
// dataLoader.ts
|
|
import { writable } from 'svelte/store';
|
|
import dataSources from 'virtual:data-sources-list';
|
|
|
|
// The store that holds the data sets
|
|
export const queryStore = writable({});
|
|
|
|
// Dynamically import the data modules and assign them to the store
|
|
dataSources.forEach(src => {
|
|
import(`/src/lib/data/${src}.ts`).then(module => {
|
|
// Here, explicitly extract the required data or function from the module
|
|
const moduleData = module[src] || module.default;
|
|
|
|
queryStore.update(store => ({ ...store, [src]: moduleData }));
|
|
});
|
|
}); |