Merge executeCallbacks and runCallback, simplify + optimize

This commit is contained in:
Aarni Koskela 2023-05-25 09:02:38 +03:00
parent f661fb0fd3
commit 9574ebe212

View File

@ -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;