Created
January 8, 2020 21:46
-
-
Save jarmitage/e44ca7ffc6b9794e09dbfa9913dcf483 to your computer and use it in GitHub Desktop.
Svelte store pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { writable } from "svelte/store" | |
const createStore = () => { | |
let state = { | |
} | |
const { subscribe, set, update } = writable(state) | |
const methods = { | |
init: () => { /* */ }, | |
reset: () => { return set(state) } | |
} | |
return { subscribe, set, update, ...methods } | |
} | |
export const Store = createStore() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment