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: Managing multiple VO's from different Proxies.  (Read 6739 times)
erik.shortplay
Newbie
*
Posts: 2


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



View Profile WWW Email
« Reply #1 on: December 20, 2009, 03:00:13 »

My first question is the way I am instantiating and accessing these 3 VO's correct or appropriate?
Certainly looks as if it should work to me.

:
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?"The way you're doing it here seems to work, considering the way the data comes in from different services. I'm not sure why they have to be combined in the ManagerProxy, though, but it's certainly valid to form part/whole hierarchies in the Model.

-=Cliff>
Logged
erik.shortplay
Newbie
*
Posts: 2


View Profile Email
« Reply #2 on: December 20, 2009, 03:47:27 »

Hello,

Thanks for the reply, I justed wanted to know if I was on the right track with accessing these four proxies in the ManagerCommand like this. 
Is using the notification.getBody() in this Manager-command to pass the vo immediately also okay to do?

Beside that i found also another way to do the same, which I have a question about..
In this way I use the Second_Proxy with its SecondVO, I initialize an extra VO, called ListVO.
First I fill all the SecondVO with its data following by pushing this VO with an explicit setter in a Array (_secondVOList )  in the extra ListVO.

Except now I need this ListVO also to be present (to fill it the same way) in the ThirdVO and FourthVO. Instantiating this ListVO in these Proxies would result not having the same (reference) ListVO as the Second_Proxy. Right?

What is the best way to get the reference of this ListVO instantiated in the Second_Proxy into
the Third_Proxy and Fourth_proxy?

(so i can later use only this ListVO for doing the business in the ManagerProxy instead of 3 different VO's, written in the post above).

Again a bit abstract post…Sorry for that.


Erik

Logged
Pages: [1]
Print