rgoodrow
03/06/2019, 7:26 PMreturn {
post: function (context) {
switch (context.action) {
case 'doStuff': return doStuff(context);
}
}
};
I'd like to clean up to
return {
post: function(context) {
return <parentObject>[context.action](context);
}
};
battk
03/06/2019, 8:44 PMvar parentObject = {doStuff: function(){}}
return {
post: function(context) {
return parentObject[context.action](context);
}
};
rgoodrow
03/06/2019, 8:46 PMjkabot
03/06/2019, 8:56 PM<parentObject>
mapping names to functions until you make one.rgoodrow
03/06/2019, 8:57 PMthis
that I could call from within itrgoodrow
03/06/2019, 8:57 PMthis
would be the <parentObject>
jkabot
03/06/2019, 8:58 PMjkabot
03/06/2019, 8:59 PMlocals()
.rgoodrow
03/06/2019, 9:00 PMjkabot
03/06/2019, 9:01 PMbattk
03/06/2019, 9:06 PMbattk
03/06/2019, 9:07 PMreturn {
doStuff: function(){},
post: function(context) {
return this[context.action](context);
}
};
rgoodrow
03/06/2019, 9:15 PMthis
in that context isn't referencing the closure defined as part of define()
rgoodrow
03/06/2019, 9:15 PMjkabot
03/06/2019, 9:20 PMjkabot
03/06/2019, 9:21 PMrgoodrow
03/06/2019, 9:38 PM