PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: Allen on September 04, 2008, 05:43:02



Title: Interpretting Menu Selection
Post by: Allen on September 04, 2008, 05:43:02
Hello.

I have a List that contains a number of icon-buttons. It is kind of a utility bar and each button does something unrelated to the others - one pops open a panel, another resizes the screen, another saves the current setup etc. Each button renderer has a unique ID in its data property.

My question is where does the interpretation of the buttons' ids take place? Should the List's mediator just send an ICON_SELECTED notification with the id as the body and have a Command use a switch statement on the id to decide what action to take?



Title: Re: Interpretting Menu Selection
Post by: puremvc on September 04, 2008, 03:32:44
It would be better to move that switch statement to the event handler in the mediator and have it send notifications that are specific to the function you're wanting to trigger. Why? The I'd of the view component is pretty specific to the view component. And consider you might want, for instance, keystrokes from the stage or selections from a context menu to trigger the same actions. Their mediators would evaluate their events send the same use-case specific notifications (like AppFacade.SAVE, AppFacade.RESIZE, etc.

-=Cliff>


Title: Re: Interpretting Menu Selection
Post by: Allen on September 11, 2008, 05:11:31
Thanks for your reply.

I guess that does make sense. I was thinking that all decision making should be made in the Commands, but I suppose that would make the Mediators redundant beyond relaying info to and from their components.