PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: martypitt on December 03, 2007, 11:25:05



Title: Newbie Question - User - singleton?
Post by: martypitt on December 03, 2007, 11:25:05
Hi

I have a fairly simple question.... Across my application, various components need to know about who the user is.

How do I expose this type of singleton style data?  Do I expose a :

public function get userProxy():UserProxy

on the ApplicationFacade?

then when I need to know who the user is, I target ApplicationFacade.getInstance.userProxy.userName()?

Or is there a more appropriate approach?

Thanks


Marty


Title: Re: Newbie Question - User - singleton?
Post by: puremvc on December 04, 2007, 07:09:06
This sounds like your planning to bind to this expression.

But bindig isn't available everywhere PureMVC is so binding in a PureMVC app is pretty much limited to blackbox wiring *inside* a view component.

We use a Mediator to connect a view component to its data by retrieving the reference from the Proxy and setting it on the view component in question.

-=Cliff>


Title: Re: Newbie Question - User - singleton?
Post by: martypitt on December 06, 2007, 02:33:16
Thanks Cliff


Title: Re: Newbie Question - User - singleton?
Post by: cliffrowley on December 21, 2007, 01:24:21
I don't know if this is strictly related, but I use a ProxyHelper class which exposes Proxy instances for me as a convenience.  Then I can reduce:

var proxy:SomeProxy = facade.retrieveProxy(SomeProxy.NAME) as SomeProxy;

to

var proxy:SomeProxy = ProxyHelper.getSomeProxy();