Dispatching Events with Cairngorm 2.2.1

While trawling through the CairngormEvent.as I noticed the distpatch() method which in essence calls the same code that was needed in the previous versions of Cairngorm.

Pre Cairngorm 2.2 example

var userVO : UserVO = ModelLocator.getInstance().userVO;
var event : LoginChangeEvent = new LoginChangeEvent(LoginChangeEvent.LOGOUT_EVENT,userVO);

/* dispatch the event */
CairngormEventDispatcher.getInstance().dispatchEvent( event );

Latest example

var userVO : UserVO = ModelLocator.getInstance().userVO;
var event : LoginChangeEvent = new LoginChangeEvent(LoginChangeEvent.LOGOUT_EVENT,userVO);

/* dispatch the event */
event.dispatch();

It just saves having to import the CairngormEventDispatcher and typing those extra characters. Which can save a lot of time if you’re a chicken pecker typist 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *