You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
743 B

import { writable } from "svelte/store";
import stuffLogClient from "../clients/stufflog";
import type { GroupResult } from "../models/group";
interface GroupStoreData {
loading: boolean
stale: boolean
groups: GroupResult[]
}
function createGroupStore() {
const {update, subscribe} = writable<GroupStoreData>({
loading: false,
stale: true,
groups: [],
});
return {
subscribe,
markStale() {
update(v => ({...v, stale: true}));
},
async load() {
update(v => ({...v, loading: true}));
const groups = await stuffLogClient.listGroups();
update(v => ({...v, loading: false, stale: false, groups}));
},
}
}
const groupStore = createGroupStore();
export default groupStore;