Merge executeCallbacks and runCallback, simplify + optimize
This commit is contained in:
parent
f661fb0fd3
commit
9574ebe212
16
script.js
16
script.js
@ -37,17 +37,15 @@ function onOptionsChanged(callback) {
|
|||||||
optionsChangedCallbacks.push(callback);
|
optionsChangedCallbacks.push(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function runCallback(x, m) {
|
function executeCallbacks(queue, arg) {
|
||||||
try {
|
for (const callback of queue) {
|
||||||
x(m);
|
try {
|
||||||
} catch (e) {
|
callback(arg);
|
||||||
console.error("error running callback", x, ":", e);
|
} catch (e) {
|
||||||
|
console.error("error running callback", callback, ":", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function executeCallbacks(queue, m) {
|
|
||||||
queue.forEach(function(x) {
|
|
||||||
runCallback(x, m);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var executedOnLoaded = false;
|
var executedOnLoaded = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user