Ok, so I am currently trying to clean up the spaghetti that is our current ApplicationFacade and its immediate mediators. Our application is dependent upon settings that are located in the flashVars of the encapsulating HTML object tag (we use swfobject if you're curious). From those vars we determine what database the application should then retrieve its information from (these settings are downloaded from a url in flashVars).
Currently, flash vars are grabbed inside the facade class and then a url request is launched via URLLoader then and there. When the request comes back, more fun stuff is done where the facade--which kept a global reference to the Application instance it received in the startUp() command--passes the URLoader's result to the application view component (yeah! who needs a Mediator, right?).
Well, all this works, but I feel like to is definitely not correct (correct me
if I am wrong).
The place where I am particularly facing a moral conundrum is the flashvars itself.
Here's part one of my question:
I feel as though the flash vars should have its own proxy (registered in the new StartUpCommand) but flashvars comes directly from the view component via: view.root.loaderInfo.parameters.
I could just pass that object in the StartUpCommand:
facade.registerProxy(new FlashVarsProxy("FlashVarsProxy", body.root.loaderInfo.parameters)) //body is an instance of Application
But since its bound directly to the application instance, should it be handled inside the Mediator as a sort of public var?
And now for part two of my question:
Once I decide what to do with the flash vars, who/what should be responsible for the URLLoader request for remote variables based on those flash vars?
Again, I am leaning towards just declaring a proxy for that in the StartUpCommand and setting a search parameter based on the flash vars. Perhaps via the FlashVarsProxy I register on the line just before it (or not)?
var systemConfigProxy = SystemConfigProxy(facade.registerProxy(new SystemConfigProxy()));
systemConfigProxy.dataURL = body.root.loaderInfo.parameters.serverURL; //and now wait for notification when the URLLoader is complete
Any thoughts much appreciated, no matter how detailed or specific!