Skip to content

Instantly share code, notes, and snippets.

@jarmitage
Created January 8, 2020 21:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarmitage/e44ca7ffc6b9794e09dbfa9913dcf483 to your computer and use it in GitHub Desktop.
Save jarmitage/e44ca7ffc6b9794e09dbfa9913dcf483 to your computer and use it in GitHub Desktop.
Svelte store pattern
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