Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: using the same Command ?  (Read 7115 times)
davidTikva
Jr. Member
**
Posts: 12


View Profile Email
« 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 :)
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>
Logged
davidTikva
Jr. Member
**
Posts: 12


View Profile Email
« Reply #2 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
Logged
Pages: [1]
Print