By: thomasb

Updated 3 months, 3 weeks ago

Source: http://www.gridlinked.info/

Eyu, you have made an excellent an astute point. True, callbacks is a 1-to-1 connection between the request originator and the response. If you have a need for multiple callbacks (e.g. more than 1 listener wants to be notified), then use either the ModelLocator databinding approach OR you can create a special dispatcher that supports originators to register for events… think of this an “event bus/pipeline” for your special needs. Unfortunately event bus architectures are ALWAYS ...

  • 16 comments on this story
PRO

50% positive

Showing 12 relevant reactions out of 16.

Cairngorm Secret Tip #3: Responders for View Notifications http://bit.ly/85oCFr //Excelente! #Flex #Cairngorm

3 months, 3 weeks ago by otakurzo on Twitter

Eyu, you have made an excellent an astute point. True, callbacks is a 1-to-1 connection between the request originator and the response. If you have a need for multiple callbacks (e.g. more than 1 listener wants to be notified), then use either the ModelLocator databinding approach OR you can create a special dispatcher that supports originators to register for events… think of this an “event ... See all content

4 months, 3 weeks ago by thomasb on Wordpress

This is why the CGX (Cairngorm extensions) Command class has a notifyCaller() method. That method checks for a valid callback closure. Don’t forget to call super.execute() in the Command::execute() method…

4 months, 3 weeks ago by thomasb on Wordpress

Databinding is certainly cleaner than callbacks. However, if you have a single view/component instance that wants specific data (without databinding triggers to other instances), then callbacks is probably the cleanest solution. Remember that logic in presentation models works great. Heavy-loading logic in presentation components is not recommended. Instead create facade or delegate classes to manage ... See all content

4 months, 3 weeks ago by thomasb on Wordpress

Thanks pyso,

As with all good intentions, reality often delays my blogging or responses.

Secrets #1 and #2 are postponed… but I am two upcoming blog entries that you will LOVE.

4 months, 3 weeks ago by thomasb on Wordpress

Remember that your command MUST call super.execute(event) in order to cache any callbacks to views.

e.g.

override public function execute(event:CairngormEvent):void {

super.execute(event);

switch(event.type) {



}

}

AND your response handlers must in turn always invoke a notifyCaller() to notify view or other originating
... See all content

4 months, 3 weeks ago by thomasb on Wordpress

Note that dependency injectors are already available in the Mate MVC. And… best of all, you can use the Mate EventMaps with Cairngorm. So the Mate EventMap will only have dependency injectors [MateDI] (no event handlers) AND Cairngorm has the event handlers. This is an excellent blend because MateDI supports injection into any specified class instance regardless of position in the view hierarchy ... See all content

4 months, 3 weeks ago by thomasb on Wordpress

Great article.

This saves the new “notify-view” event generation/dispatch from the command to the view.

Now we have a use case that several views are listening to the “notify-view” event generated by the command. But in your example, it seems only one callback responder can be specified in the original event. Can you suggest a way to resolve our issue?

Thanks!

4 months, 3 weeks ago by eyu on Wordpress

#cairngorm, heres a great article on using IResponder to pass view notifications http://bit.ly/2Keuls

5 months, 1 week ago by ryancanulla on Twitter

Thanks for writing up this clear explanation. And of course, thanks for clearing up some of the details of using the UM extensions a while back at the Online Flex meetup. It has helped my Flex workflow greatly.

Mani

6 months, 3 weeks ago by diamondTearz on Wordpress

Love the article, but it would be nice to see what the command class looks like, or at least a link to an example.

If I am understanding this correctly, since the responder is optional on the event, the command class would have to check to see if it is defined before calling it to avoid a null pointer exception correct?

So would a command result function notifying a view responder
... See all content

9 months ago by Jeremy Wischusen on Wordpress

Hey this has helped me a lot. Thank you very much. I’ll be waiting for your “3 Methods for Component Couplings in Flex” article. [:)]

9 months, 3 weeks ago by Prasanta Saha on Wordpress

© uberVU Ltd. 2010

Terms of use
FEEDBACK