I've used PureMVC for a couple of projects now and I'm very happy with it. In my current project I have quite a few RemoteServices to handle and to mix together.
I read through some posts and decided to lay out the different service calls into delegates as different DataProxies will need to make use of them and even I want to reuse those delegates in different applications.
My question is now about a best practice how to setup/configure the proxies with the delegates?
I like to handle object configuration and object dependency layout in constructors. So currently I would go with something like this:
public class ConfigureProxiesCommand extends SimpleCommand {
override public function execute(notification:INotification):void {
var configProxy:ConfigProxy = facade.retrieveProxy(ConfigProxy.NAME) as ConfigProxy;
var delegate:SomeDelegate = new SomeDelegate(configProxy.gatewayUrl);
facade.registerProxy(new RemoteProxyA(delegate));
facade.registerProxy(new RemoteProxyB(delegate));
}
}
Since the config data is retrieved ansync via XML, I now have to locations/commands for my modelsetup: ModelPrepCommand and ConfigureProxiesCommand as I can setup my delegates as soon as config data is available. What I'm not really happy with.
Also I've never seen any example where a delegate was instantiated in a command.
Any suggestions on a different/better approach on this?
thanks,
chris