ericbirdsall
03/22/2021, 8:00 PM[
ocUserEvents.functionOne(context),
ocUserEvents.functionTwo(context)
].forEach(fn => {
try {
fn();
} catch (error) {
if (error == 'TypeError: fn is not a function') return;
log.error({
title: "error on afterSubmit",
details: error,
});
}
});
battk
03/22/2021, 8:03 PMbattk
03/22/2021, 8:03 PMocUserEvents.functionOne(context)
is not normally what I would expect a function that returns a function to look likeericbirdsall
03/22/2021, 8:05 PMreturn {
functionOne: function(context){
//do stuff here
},
functionTwo: function(context){
//do other stuff here
},
}
ericbirdsall
03/22/2021, 8:06 PMbattk
03/22/2021, 8:06 PMfunctionOne: function(context){
throw new Error('This should be more obvious')
}
battk
03/22/2021, 8:06 PMericbirdsall
03/22/2021, 8:08 PMbattk
03/22/2021, 8:08 PMericbirdsall
03/22/2021, 8:10 PMbattk
03/22/2021, 8:10 PMericbirdsall
03/22/2021, 8:10 PMericbirdsall
03/22/2021, 8:15 PMericbirdsall
03/22/2021, 8:16 PMstalbert
03/22/2021, 8:16 PMericbirdsall
03/22/2021, 8:17 PMbattk
03/22/2021, 8:19 PMbattk
03/22/2021, 8:20 PMstalbert
03/22/2021, 8:20 PM_.partial(ocUserEvents.functionOne, context)
instead of ocUserEvents.functionOne(context)
ericbirdsall
03/22/2021, 8:22 PMstalbert
03/22/2021, 8:23 PMfunctions as values
complexity is really adding value I'd avoid it.ericbirdsall
03/22/2021, 8:23 PM[
ocUserEvents.functionOne,
ocUserEvents.functionTwo
].forEach(fn => {
try {
fn(context);
} catch (error) {
log.error({
title: "error on afterSubmit",
details: error,
});
}
});
battk
03/22/2021, 8:23 PMbattk
03/22/2021, 8:24 PMericbirdsall
03/22/2021, 8:24 PMericbirdsall
03/22/2021, 8:26 PMbattk
03/22/2021, 8:26 PMericbirdsall
03/22/2021, 8:30 PMbattk
03/22/2021, 8:32 PMericbirdsall
03/22/2021, 8:38 PM