Signals may spell the death to my Commands as I know them
Back when I wrote my Command library I was doing a lot of calling of commands. It actually stems from the Commands/Delegates I created for the Facebook AS3 API (which have since been removed; which I think is a shame). Essentially the greatest benefit I got from my commands with the ability to do this:
commandInstance.addCallback(onComplete);
function onComplete(commandInstance:CommandClass):void
{ // do stuff }
function onComplete(commandInstance:CommandClass):void
{ // do stuff }
instead of this:
commandInstance.addEventListener(Event.COMPLETE, onComplete);
function onComplete(e:Event):void
{
var commandInstance:CommandClass = e.target as CommandClass;
commandInstance.removeEventListener(Event.COMPLETE, onComplete);
//NOW I can do stuff
}
function onComplete(e:Event):void
{
var commandInstance:CommandClass = e.target as CommandClass;
commandInstance.removeEventListener(Event.COMPLETE, onComplete);
//NOW I can do stuff
}
That got rid of a lot of code for me and made me very happy.
Boss: Jason, how many lines of code did you write today?
Me: (proudly) Negative two-hundred-sixty-nine!
Just kidding. My boss has never asked me how many lines of code I wrote.
Read more