[Arp] Commands in ARP 3?

JesterXL jesterxl at jessewarden.com
Mon Mar 6 10:36:49 PST 2006


Yo, been extremely busy so haven't been able to keep up on the status of ARP 
3.  And since I hate Cairngorm's implementation of stateless commands, I 
built my own temporary CommandRegistry in AS3 for use in Flex 2.

I ran into a conundrum like 2 weeks again, got extremely frustrated, and 
left.  Today, I think I found a solution.

Cairngorm allows a 2nd parameter in it's EventBroadcaster, the main thing 
that fires off Commands.  This 2nd parameter becomes the data property to 
the object passed into the Command's execute function.

So if you did:

EventBroadcaster.broadcastEvent(Constant.EventName, {yo: "hey"} );

Then your' command would look something like this:

function execute ( eventObj )
{
    trace(eventObj.data.yo) ; // hey
}

Granted, Cairngorm 2 now actually passes a CairngormEvent.  All it is is a 
class that extends event with an un-typed parameter, data, so you can do the 
same thing in AS3.

However, the whole point of event classes is having strong typing, and clear 
intent.  If you change from this:

dispatchEvent ( {type: "click", target: this } );

to this:

var e:MouseEvent = new MouseEvent( MouseEvent.CLICK );
dispatchEvent(e);

You are a lot more clear to what you are sending, as well as those who 
receive the event know EXACTLY what they are getting:

function onClick ( event : MouseEvent )
{

}

Therefore, is ARP 3 going to have events passed to the execute function, or 
what?  If so, this will help define context of the Command.  Even though 
they are supposed to be use case specific, they are still classes, and thus 
re-usable implied.  So, it'd be nice to have events to allow them to be 
flexible enough based on the event passed to them, which also gives them 
parameters.

If anyone remembers my hack to allow events to receive parameters, it blows 
in AS3 since override is so damn strict.  I miss AS2 already:

override public function execute(... args):void

Notice I now have to go:

var username = args[0];
var password = args[1];

That is teh suck...

So uh... Aral... like, how are commands implemented in ARP 3?

--JesterXL




More information about the Arp mailing list