PureMVC Architects Lounge

PureMVC Manifold => Standard Version => Topic started by: i_am_cam on January 23, 2009, 08:35:43



Title: Passing multiple values to a command
Post by: i_am_cam on January 23, 2009, 08:35:43
I have a command, FullScreenCommand, which requires two key elements in order to function; an event which has fired (I need to check it's type) and a reference to the application itself (so I can change the displayState of the stage).

I'm passing the event via the notification body, the reference to the application I'm obtaining within the command as follows;

:
var applicationMediator:ApplicationMediator = facade.retrieveMediator(ApplicationMediator.NAME) as ApplicationMediator;
var app:MyApp = applicationMediator.getViewComponent() as MyApp;

Does this fit with the PureMVC principles, or should I be passing both the event and app instance via the body of a custom notification?

Thanks :)


Title: Re: Passing multiple values to a command
Post by: Jason MacDonald on January 23, 2009, 12:15:23
There's nothing wrong with a command accessing a mediators public properties. You just don't want proxies accessing mediators.


Title: Re: Passing multiple values to a command
Post by: puremvc on January 25, 2009, 07:44:52
Really what you want to do is send a notification from the command that the Application or Stage Mediator is interested in. That mediator should be the only object in the system interacting with the app or the stage. That's the point of having a mediator.

-=Cliff>


Title: Re: Passing multiple values to a command
Post by: i_am_cam on January 26, 2009, 03:40:03
Thanks for the reply Cliff, that makes a lot of sense.