1
0
mirror of https://github.com/comatory/fb2iCal synced 2025-06-05 22:09:25 +02:00

feature: sync multiple tabs using local storage

This commit is contained in:
Ondřej Synáček
2020-12-15 21:16:30 +01:00
parent 61985990d0
commit e28b378e07
5 changed files with 59 additions and 12 deletions

View File

@ -6,24 +6,18 @@ const createConfigStore = () => {
const { subscribe, set, update } = writable(state)
const setValue = (key, value) => {
update((prevState) => {
const nextState = {
...prevState,
[key]: value,
}
localStorage.setItem('fb-to-ical-config', JSON.stringify(nextState))
return nextState
})
update((prevState) => ({ ...prevState, [key]: value }))
}
const getState = () => state
return {
...state,
subscribe,
set,
update,
setValue,
getState,
}
}