Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
March 23, 2017, 03:08:37 PM
Home Help Search Login Register
News: ATTENTION: Spambots must die! Humans must visit http://contact.futurescale.com to request forum access.
Pages: [1]
Print
Author Topic: Caching references to other proxies in a proxy  (Read 2070 times)
hesten
Sr. Member
****
Posts: 52


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

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: 2860



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

Quote
Where would I put something like:

Code:
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
« Reply #2 on: May 22, 2012, 11:22:53 PM »

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
Jump to: