КС
export function loadResources(resources) {
return Promise.all(
resources.map(r => fetchRest(r.endpoint))
).then(res => {
resources.forEach((r, i) => r.store.set(r.pre ? r.pre(res[i]) : res[i]));
});
}
import { loadAll as funkyOtherStuff } from '@/anotherModule/store.js';
export const something = writable([]);
export const rhymesboi = writable([]);
export const loadAll = Promise.all([
loadResources([
{
endpoint: '/api/something/',
store: something
},
{
endpoint: 'rhymesboi.il',
store: rhymesboi,
pre: v => parseMd(v)
}
]),
funkyOtherStuff
]);
а вот мой велосипед)