PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: shwami on May 30, 2012, 01:47:49



Title: Need help with Architecture
Post by: shwami on May 30, 2012, 01:47:49
Hello,

my query is this:
can we have two proxies that can communicate with each other? I have one proxy that talks to a remote server and receives update messages. My other proxy holds configuration data for my application. Sometimes, the first proxy receives configuration messages from the remote server that need to be passed on to the configuration proxy. how can i implement this?

cheers!
Siddharth


Title: Re: Need help with Architecture
Post by: puremvc on May 30, 2012, 07:41:21
Sure. If one proxy is dependent upon another proxy, just define the first proxy to take the second one as a required constructor argument. In the constructor of that first proxy, store the reference to the second one in a protected property.

You could have the first one retrieve the second one via the Facade, but there is always the possibility that will fail, if the other proxy is not yet registered. By passing the reference to the second proxy on the constructor, you ensure that it will be present as soon as it is needed, and forces you to create and register them in the right order.