move execution into function

This commit is contained in:
iw0 2024-06-04 21:36:38 +02:00
parent 75a5b71a0a
commit 62a08c9166

View File

@ -62,21 +62,28 @@ const personalDataConfigKeys = [
"addr__email", "addr__street", "addr__postcode", "addr__placename"]; "addr__email", "addr__street", "addr__postcode", "addr__placename"];
const bankDetailConfigKeys = ["pymt__iban", "pymt__bic"]; const bankDetailConfigKeys = ["pymt__iban", "pymt__bic"];
/** const genericExecute = (stage, o) => {
* @param {Node} n const success = stage.execute(o);
*/ Promise.resolve(success).then(result => {
function processSingleAddedNode(n) {
if (currentStage.match(n)) {
console.info(currentStage.name, "matched: ", n);
const success = currentStage.execute(n);
Promise.resolve(success).then((result => {
if (result === true) { if (result === true) {
console.info(currentStage.name, "executed successfully"); console.info(currentStage.name, "executed successfully");
} else { } else {
console.error(currentStage.name, "failed"); console.error(currentStage.name, "failed");
} }
nextStage(); nextStage();
})); }, failReason => {
console.error(currentStage.name, "failed: ", failReason);
});
}
/**
* @param {Node} n
*/
function processSingleAddedNode(n) {
if (currentStage.match(n)) {
console.info(currentStage.name, "matched: ", n);
genericExecute(currentStage, n);
} else { } else {
console.debug(currentStage.name, "did not match: ", n); console.debug(currentStage.name, "did not match: ", n);
@ -110,13 +117,7 @@ function processMutations(mutationList, observer) {
if (currentStage.expects == 'mutation') { if (currentStage.expects == 'mutation') {
if (currentStage.match(mutation)) { if (currentStage.match(mutation)) {
console.info(currentStage.name, "matched: ", mutation); console.info(currentStage.name, "matched: ", mutation);
let success = currentStage.execute(mutation); genericExecute(currentStage, mutation);
if (success){
console.info(currentStage.name, "executed successfully");
} else {
console.error(currentStage.name, "failed");
}
nextStage();
} else { } else {
console.debug(currentStage.name, "did not match: ", mutation); console.debug(currentStage.name, "did not match: ", mutation);
} }