Flex: Cairngorm 2.2 Events
I have been updating my flex version of gTraffic to the recently released version of Cairngorm. One of the changes it that there is a new means of dispatching Cairngorm events. It used to be:
CairngormEventDispatcher.getInstance().
dispatchEvent(new GetRegionsEvent());
and now it’s
var event:CairngormEvent = new GetRegionsEvent();
event.dispatch();
I have a problem with this which is that it’s not very explicit especially if you rewrite it as:
var event:GetRegionsEvent = new GetRegionsEvent();
event.dispatch();
At least the original way you were firmly in Cairngorm-land and knew it. If you rewrite it the second way then looking at it it doesn’t seem totally clear unless you are aware that only CairngormEvent has a dispatch method.
I guess the Cairngorm guys know what they are doing but experience has taught me to be very wary of putting in a ’shortcut’ like this. Too much scope to confuse a developer looking at a Flex/Cairngorm application which might have a mix of both Flex bog-standard events and Cairngorm events.
Comments
Leave a Reply