add settings reset button
This commit is contained in:
parent
7994ba8b38
commit
a21b3d788f
3 changed files with 19 additions and 3 deletions
|
|
@ -20,7 +20,7 @@ export function set(next) {
|
|||
localStorage.setItem(storeKey, JSON.stringify(next));
|
||||
}
|
||||
|
||||
export function updateState(func) {
|
||||
export function update(func) {
|
||||
const prev = get();
|
||||
const next = func(prev);
|
||||
set(next);
|
||||
|
|
@ -31,6 +31,10 @@ export function updateState(func) {
|
|||
);
|
||||
}
|
||||
|
||||
export function reset() {
|
||||
update(() => defaults);
|
||||
}
|
||||
|
||||
export function watch(func, prop) {
|
||||
document.addEventListener(storeKey, (e) => {
|
||||
const { prev, next } = e.detail;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue