Implement food and settings stores
This commit is contained in:
22
frontend/src/lib/store/SettingsStore.ts
Normal file
22
frontend/src/lib/store/SettingsStore.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { type Writable, writable } from "svelte/store";
|
||||
import { main } from "$wails/models";
|
||||
import { GetSettings } from "$wails/main/App";
|
||||
|
||||
async function createStore(): Promise<Writable<main.settings>> {
|
||||
// This should never fail
|
||||
const settings: main.settings = await GetSettings();
|
||||
|
||||
const { subscribe, update, set } = writable(settings);
|
||||
return {
|
||||
subscribe,
|
||||
update,
|
||||
set,
|
||||
// @ts-ignore
|
||||
refresh: async () => {
|
||||
const settings: main.settings = await GetSettings();
|
||||
set(settings);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export const settingsStore = await createStore();
|
Reference in New Issue
Block a user