fixed broken watcher

This commit is contained in:
Nathan DECHER 2020-04-06 11:12:45 +02:00
parent d339dd0a06
commit 0578bfb6ad

View file

@ -7,6 +7,13 @@ const toBoolean=v => {
if(v=='false' || v==false) return false; if(v=='false' || v==false) return false;
return true; 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 => { const get=key => {
let confVal=localStorage.getItem('config.'+key); let confVal=localStorage.getItem('config.'+key);
@ -19,14 +26,12 @@ const getS=key => ''+get(key);
const set=(key, value) => { const set=(key, value) => {
localStorage.setItem('config.'+key, value); localStorage.setItem('config.'+key, value);
let interested=watchers[key]; notify(key, value);
if(interested) interested.forEach(watcher => watcher(key, value));
}; };
const remove=key => { const remove=key => {
localStorage.removeItem('config.'+key, value); localStorage.removeItem('config.'+key, value);
let interested=watchers[key]; notify(key, assets.get('config')[key]);
if(interested) interested.forEach(watcher => watcher(key, assets.get('config')[key]));
}; };
const clear=() => const clear=() =>
Object Object