generated from dave/wails-template
Add Nowstore
This commit is contained in:
24
frontend/src/lib/store/nowStore.ts
Normal file
24
frontend/src/lib/store/nowStore.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { type Writable, writable } from "svelte/store";
|
||||
|
||||
async function createStore(): Promise<Writable<Date> & { next: Function; prev: Function }> {
|
||||
const { subscribe, update, set } = writable(new Date());
|
||||
return {
|
||||
subscribe,
|
||||
update,
|
||||
set,
|
||||
next: () => {
|
||||
update((now: Date) => {
|
||||
now.setMonth(now.getMonth() + 1);
|
||||
return now
|
||||
});
|
||||
},
|
||||
prev: () => {
|
||||
update((now: Date) => {
|
||||
now.setMonth(now.getMonth() - 1);
|
||||
return now
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export const nowStore = await createStore();
|
||||
Reference in New Issue
Block a user