Move collection to store module

This commit is contained in:
Jon Staab
2025-04-25 10:37:57 -07:00
parent d14ae2ce77
commit 37c0491d71
22 changed files with 325 additions and 987 deletions
+11
View File
@@ -0,0 +1,11 @@
import {writable} from "svelte/store"
import {getJson, setJson} from "@welshman/lib"
export const synced = <T>(key: string, defaultValue: T) => {
const init = getJson(key)
const store = writable<T>(init === undefined ? defaultValue : init)
store.subscribe((value: T) => setJson(key, value))
return store
}