erik.shortplay
|
![](http://forums.puremvc.org/Themes/PureMVC/images/post/xx.gif.pagespeed.ce.G0yTW6LI8E.gif) |
« on: December 20, 2009, 10:56:28 » |
|
Hello,
I am fairly new to PureMVC, but have a few question regarding a application I am trying to make. The questions are related to what is good practice with PureMVC. I will try to explaing :
I have one ServiceCommand, which has 4 Proxy's: - First_Proxy with 3 VO's : Login_VO, Logout_VO, Ping_VO; - Second_Proxy with 1 VO : SecondVO; - Third_Proxy with 1 VO : ThirdVO; - Fourth_Proxy with 1 VO : FourthVO
I use this one ServiceCommand for all the Proxies, since every proxy needs to do his own asynchronous calls to the Server( which are timing-critical) and handling the data to its own VO's.
For the first Proxy i use this code to initialize the three VO;
public function First_Proxy() { super( NAME, { loginvo:new Login_VO(), logoffvo:new Logout_VO(), pingvo:new Ping_VO() } ); } to access them when handling the calls like this:
public function get loginvo():Login_VO { return data.loginvo as Login_VO; } public function get logoffvo():LogoffVO { return data.logoffvo as LogoffVO; } public function get pingvo():PingVO { return data.pingvo as PingVO; }
My first question is the way I am instantiating and accessing these 3 VO's correct or appropriate?
Second explaniation: I want the VO's to come "together", especially the SecondVO, ThirdVO, FourthVO. These VO are containing data, which I would like to combine to one VO by a ManageCommand and ManagerProxy. Since the server-calls in these related Proxies ( Second_Proxy, Third_Proxy or Fourth_Proxy) are done with different timing, i cant make this one VO immediately (actually I could, but rather don't since the ManagerProxy had to still manipulate some data from the different VO's).
So the ManageCommand gets a notification (through the facade) from one of the related Proxies, and then retrieves in the ManageCommand through a reference of a Proxy the according VO to pass to its own Proxy( the ManageProxy ), where all combining of these VO's is done.
override public function execute(notification:INotification):void { var name:String = notification.getName(); switch (name) { case ApplicationFacade.SECOND_PROXY_DONE: proxy.listvo = second_proxy.listvo; proxy.update(); break; case ApplicationFacade.THIRD_PROXY_DONE: proxy.thirdlistvo = third_proxy.listvo; proxy_update(); break; ... the same for the Fourth proxy… ... } }
private function get second_proxy():Second_Proxy { return facade.retrieveProxy( Second_Proxy.NAME ) as Second_Proxy; } private function get proxy():ManagerProxy { return facade.retrieveProxy( ManagerProxy.NAME ) as ManagerProxy; } Another way i was thinking to go to pass the according VO from one of the Proxies ( Second_Proxy, Third_Proxy or Fourth_Proxy) through the notification-body.
So my second question is "how to approach different VO's from different Proxies in such a way the can be combined by one ManagingProxy?"
Or is there a better way of doing these, keeping the initial Proxies ( Second_Proxy, Third_Proxy or Fourth_Proxy) in and working separately?
Sorry for the fuzzy-and non-technical explanation, but I hope it made something "clear" regarding to my questions?
Erik
|