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