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:
sendNotification(UserCommand.GET_USER, [UserColumn.EMAIL, UserColumn.NAME]);
UserCommand sends the request to UserProxy:
userProxy.getUser(notification.getBody() as Array);
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:
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..