fixed broken watcher
This commit is contained in:
parent
d339dd0a06
commit
0578bfb6ad
1 changed files with 9 additions and 4 deletions
|
@ -7,6 +7,13 @@ const toBoolean=v => {
|
|||
if(v=='false' || v==false) return false;
|
||||
return true;
|
||||
};
|
||||
const notify=(key, value) => {
|
||||
const interested=watchers[key];
|
||||
if(interested) Object
|
||||
.keys(interested)
|
||||
.map(key => interested[key])
|
||||
.forEach(fn => fn(key, value));
|
||||
};
|
||||
|
||||
const get=key => {
|
||||
let confVal=localStorage.getItem('config.'+key);
|
||||
|
@ -19,14 +26,12 @@ const getS=key => ''+get(key);
|
|||
|
||||
const set=(key, value) => {
|
||||
localStorage.setItem('config.'+key, value);
|
||||
let interested=watchers[key];
|
||||
if(interested) interested.forEach(watcher => watcher(key, value));
|
||||
notify(key, value);
|
||||
};
|
||||
|
||||
const remove=key => {
|
||||
localStorage.removeItem('config.'+key, value);
|
||||
let interested=watchers[key];
|
||||
if(interested) interested.forEach(watcher => watcher(key, assets.get('config')[key]));
|
||||
notify(key, assets.get('config')[key]);
|
||||
};
|
||||
const clear=() =>
|
||||
Object
|
||||
|
|
Loading…
Reference in a new issue