1
0
mirror of https://github.com/comatory/fb2iCal synced 2025-02-14 10:40:54 +01:00
2020-12-20 15:24:25 +01:00

27 lines
518 B
JavaScript

import { writable } from 'svelte/store'
import { STORAGE_KEYS } from '../constants'
const createConfigStore = () => {
const state = JSON.parse(localStorage.getItem(STORAGE_KEYS.CONFIG) || '{}')
const { subscribe, set, update } = writable(state)
const setValue = (key, value) => {
update((prevState) => ({ ...prevState, [key]: value }))
}
const getState = () => state
return {
...state,
subscribe,
set,
update,
setValue,
getState,
}
}
export default createConfigStore()