PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: davidTikva on August 12, 2010, 12:01:03



Title: using the same Command ?
Post by: davidTikva on August 12, 2010, 12:01:03
Hey,
I need to understand something about the architecture.
I'm building a flash game (AS3) and when the user is pressing on a character
the mediator sending a USER_INFO_COMMAND
the command speak with the Proxy to get the data

worldProxy.getUserData(id:String);

this funciton getUserData sendingNotification back to the Mediator.
is there any way to use the same Command (USER_INFO_COMMAND)
or I need to split it to 2 commands? (USER_INFO_REQUEST & USER_INFO_DATA)

what is the right way?
thank you very much :)


Title: Re: using the same Command ?
Post by: puremvc on August 13, 2010, 07:29:39
In this case you could use two commands as you've described, or you could use the type parameter as a way to switch the functionality of the command. Type could be set to UserInfoCommand.REQUEST or UserInfoCommand.REPLY, for instance, and the execute method could perform different actions based on the result of notification.getType().

Also, if the same mediator that requested the data is one needing to use it, then you can skip the command and just have the mediator retrieve the proxy, get the data and set it on the view component. The command is useful if more than one mediator is involved. For instance if you click on the character but you need another mediated component to display the information about the clicked character.

-=Cliff>


Title: Re: using the same Command ?
Post by: davidTikva on August 14, 2010, 01:31:22
In this case you could use two commands as you've described, or you could use the type parameter as a way to switch the functionality of the command. Type could be set to UserInfoCommand.REQUEST or UserInfoCommand.REPLY, for instance, and the execute method could perform different actions based on the result of notification.getType().

Also, if the same mediator that requested the data is one needing to use it, then you can skip the command and just have the mediator retrieve the proxy, get the data and set it on the view component. The command is useful if more than one mediator is involved. For instance if you click on the character but you need another mediated component to display the information about the clicked character.

-=Cliff>

cool. thanks Cliff