Files
auth.andert.me/src/lib/core/refactor/queryLoader.ts
2023-08-04 17:57:22 +02:00

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 }));
});
});