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]
Author Topic: Share Values in all Models?  (Read 2075 times)
Jr. Member
Posts: 18

View Profile Email
« on: October 24, 2011, 09:22:13 »

I want to share a value (global) between all my Models. What is the most sound way to do this?

I can set these values when the application loads but where would the best place to put these values so that the Models would have access to them?

Global Moderator
Hero Member
Posts: 2871

View Profile WWW Email
« Reply #1 on: October 24, 2011, 10:25:35 »

I assume you mean your Proxies.

If these are fixed values you could put them in a constants file, of course.

If not, then you should make a Proxy for holding those values, and pass a reference to that Proxy into the constructors of the other Proxies when they are created. Have those Proxies keep the reference, and they'll all be able to collaborate with the common Proxy. And Commands and Mediators will also be able retrieve that Proxy if they need access to it.

* Constructor.
* The SandwichProxy collaborates with the
* JamProxy and the BreadProxy to ensure
* consistency of the domain data. Requiring
* them on the constructor ensures they
* will be present.
public function SandwichProxy( jamProxy:JamProxy, breadProxy:BreadProxy )
super( NAME );
this.jamProxy   = jamProxy;
this.breadProxy = breadProxy;

« Last Edit: October 24, 2011, 10:28:30 by puremvc » Logged
Pages: [1]