O'Reilly logo

Professional Cairngorm™ by Jeremy Wischusen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

23.4. Revising Registration

To see how this Responder methodology works, you are going to revise the registration feature.

First revise the UserEvent class to take in an optional IResponder parameter to be held in a new responder property.

Add the following variable to the UserEvent class:

public var responder:IResponder;

Then update the constructor to take in an optional responder parameter and assign it to the responder property:

public function UserEvent(type:String, user:UserVO = null,
responder:IResponder = null, bubbles:Boolean=false, cancelable:Boolean=false)
        {
            super(type, bubbles, cancelable);
            this.user = user;
            this.responder = responder;
        }

Now update the RegisterUserCommand. Start by adding the following property:

private var responder:IResponder;

Next, update the execute function to assign the responder passed by the event to the responder property. Additionally, remove the code that updates the registrationStatus property of the ModelLocator, as this will no longer be needed:

public function execute(event:CairngormEvent):void
        {
            var evt:UserEvent = event as UserEvent;
            this.responder = evt.responder;
            var delegate:UserDelegate = new UserDelegate(this);
            delegate.register(evt.user);
        }

Now update the result function of the RegisterUserCommand to trigger the result function of the responder passing along the event object, if one has been defined, and remove the code updating the registrationStatus property of the ModelLocator:

public function result(data:Object):void { var ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required