swap parameters in prefs.subscribe
This commit is contained in:
parent
7a50387d35
commit
ea8eaf3146
|
@ -42,7 +42,7 @@ if ('commands' in chrome) {
|
|||
|
||||
// *************************************************************************
|
||||
// set the default icon displayed after a tab is created until webNavigation kicks in
|
||||
prefs.subscribe(() => updateIcon({id: undefined}, {}), ['iconset']);
|
||||
prefs.subscribe(['iconset'], () => updateIcon({id: undefined}, {}));
|
||||
updateIcon({id: undefined}, {});
|
||||
|
||||
// *************************************************************************
|
||||
|
@ -143,7 +143,9 @@ contextMenus = Object.assign({
|
|||
}
|
||||
};
|
||||
createContextMenus();
|
||||
prefs.subscribe((id, checked) => {
|
||||
const toggleableIds = Object.keys(contextMenus).filter(key =>
|
||||
typeof prefs.readOnlyValues[key] === 'boolean');
|
||||
prefs.subscribe(toggleableIds, (id, checked) => {
|
||||
if (id === 'editor.contextDelete') {
|
||||
if (checked) {
|
||||
createContextMenus([id]);
|
||||
|
@ -153,7 +155,7 @@ contextMenus = Object.assign({
|
|||
} else {
|
||||
chrome.contextMenus.update(id, {checked}, ignoreChromeError);
|
||||
}
|
||||
}, Object.keys(contextMenus).filter(key => typeof prefs.readOnlyValues[key] === 'boolean'));
|
||||
});
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
|
|
|
@ -157,4 +157,4 @@ var updater = {
|
|||
};
|
||||
|
||||
updater.schedule();
|
||||
prefs.subscribe(updater.schedule, ['updateInterval']);
|
||||
prefs.subscribe(['updateInterval'], updater.schedule);
|
||||
|
|
|
@ -1400,7 +1400,9 @@ function initHooks() {
|
|||
$('#options h2').addEventListener('click', () => {
|
||||
setTimeout(() => prefs.set('editor.options.expanded', $('#options').open));
|
||||
});
|
||||
prefs.subscribe((key, value) => ($('#options').open = value), ['editor.options.expanded']);
|
||||
prefs.subscribe(['editor.options.expanded'], (key, value) => {
|
||||
$('#options').open = value;
|
||||
});
|
||||
|
||||
initLint();
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ function initLint() {
|
|||
|
||||
linterConfig.loadAll();
|
||||
linterConfig.watchStorage();
|
||||
prefs.subscribe(updateLinter, ['editor.linter']);
|
||||
prefs.subscribe(['editor.linter'], updateLinter);
|
||||
updateLinter();
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,10 @@ var prefs = new function Prefs() {
|
|||
}
|
||||
},
|
||||
|
||||
subscribe(listener, keys) {
|
||||
subscribe(keys, listener) {
|
||||
// keys: string[] ids
|
||||
// or a falsy value to subscribe to everything
|
||||
// listener: function (key, value)
|
||||
if (keys) {
|
||||
for (const key of keys) {
|
||||
onChange.specific.set(key, listener);
|
||||
|
@ -332,7 +335,7 @@ function setupLivePrefs(
|
|||
updateElement({id, element, force: true});
|
||||
element.addEventListener('change', onChange);
|
||||
}
|
||||
prefs.subscribe((id, value) => updateElement({id, value}), IDs);
|
||||
prefs.subscribe(IDs, (id, value) => updateElement({id, value}));
|
||||
|
||||
function onChange() {
|
||||
const value = this[checkedProps[this.id]];
|
||||
|
|
|
@ -81,7 +81,7 @@ function setupRadioButtons() {
|
|||
sets[name][prefs.get(name)].checked = true;
|
||||
}
|
||||
// listen to pref changes and update the values
|
||||
prefs.subscribe((key, value) => {
|
||||
prefs.subscribe(Object.keys(sets), (key, value) => {
|
||||
sets[key][value].checked = true;
|
||||
}, Object.keys(sets));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user