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: Caching references to other proxies in a proxy  (Read 6975 times)
hesten
Sr. Member
****
Posts: 52


View Profile Email
« on: May 21, 2012, 11:54:51 »

Hi all

Sometimes it's handy to cache references to other proxies in a proxy, so you don't have to do a lookup (facade.retrieveProxy) each time you need data from that particular proxy.

But I am unsure where to put the reference in the Proxy pseudo class in the native port.

So my question is;

Where would I put something like:

this.userProxy = this.facade.retrieveProxy(app.model.proxy.UserProxy.NAME);

In a proxy?

Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: May 22, 2012, 07:20:28 »

Where would I put something like:

:
this.userProxy = this.facade.retrieveProxy(app.model.proxy.UserProxy.NAME);

You could do this in onRegister(), however if you do this, you are making a requirement on the order in which you register your Proxys, since UserProxy needs to be registered before the Proxy that's trying to retrieve UserProxy. That's not so super, because, while you can  leave a note in the comments about how important it is that the order of Proxy registrations remain the same, it isn't *enforced*.

A better way to handle this is to pass the UserProxy into any other Proxy that needs it as a constructor argument. That forces you to have constructed the UserProxy first.
Logged
hesten
Sr. Member
****
Posts: 52


View Profile Email
« Reply #2 on: May 22, 2012, 11:22:53 »

Thanks for your answer, I forgot about onRegister in Proxies. I've made a template proxy from the "ReverseText" example, and I guess that was left out, from the class profile in that example.

Where do you specify constructor arguments in the proxies in the js native port?
Logged
Pages: [1]
Print