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

Show Posts

* | |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / General Discussion / Re: Commands vs. Notifications on: June 01, 2012, 12:58:49
Thank you very much, I changed a bit the way of gathering data and now the structure is more clear. Thanks again for your help.

Best regards, Gregory.
2  Announcements and General Discussion / General Discussion / Commands vs. Notifications on: May 24, 2012, 12:48:14
Hello Cliff, hello everyone!

I have started the adventure with PureMVC some time ago and I am fully in love with this, but there are some little things that I would like to know. My main problem is declaring Commands and Notifications. I will try to describe it as detailed as possible.

I communicate Flash app with PHP which returns JSON strings, every time I need data, I have to make a call to api.

UserMediator is a screen which makes a request to api via UserCommand:
:
facade.registerCommand(UserCommand.GET_USER, UserCommand)
[...]
sendNotification(UserCommand.GET_USER, [UserColumn.EMAIL, UserColumn.NAME]);

UserCommand sends the request to UserProxy:
:
switch(notification.getName())
{
     case GET_USER:
          userProxy.getUser(notification.getBody() as Array);
          break;
}

UserProxy sends the request forward to ApiProxy:
:
public function getUser($data:Array):void
{
      apiProxy.sendApiRequest(RequestType.USER, RequestMethod.GET, RequestAction.CURRENT, $data);
}

When ApiProxy will finish loading the data it will fire onComplete event and now data is available.. but I have problems to send it, because I can say:
:
sendNotification(UserNotification.COMPLETE, $event.target.data);

and receive it in the Mediator, but what if I will ask for more data, e.g.
:
sendNotification(UserCommand.GET_USER, [UserColumn.EMAIL, UserColumn.NAME]); //will give me email address and the name of the current users
sendNotification(UserCommand.GET_ALL_USERS, [UserColumn.ID, UserColumn.NAME]); //will give me id and the name of all users in db

and it will go to ApiProxy where it will send the same notification which is not good OR specify for each command own notification, e.g.

:
UserCommand.GET_USER -> UserNotification.USER_COMPLETE
UserCommand.GET_ALL_USERS -> UserNotification.ALL_USERS_COMPLETE

I have many things to request from api and those solutions makes my app complicated to develop..
I would like to know the best way to solve those kinds of commands/notifications..
Pages: [1]