If I create a mediator via registerMediator or create a proxy with registerProxy and I call the same function twice will I get two of each or will it grab both mediator and proxy that already exist?
Just to be clear, registerMediator and registerProxy don't actually create Mediators or Proxies they just register them. The idiom often used is that the construction of the Mediator or Proxy is nested within the call to the associated registration method.
But regardless, no, the register methods will not register overtop of an already registered Mediator or Proxy with the same name. You must unregister the previous instance first.
In case you are actually wanting to have two instances registered at the same time, you must give them different names.
Since most Mediators or Proxies only ever need a single instance, it is common to do this:
public class UserProxy extends Proxy
{
public static const NAME:String = 'UserProxy';
public function UserProxy( user:User )
{
super ( NAME, user );
}
}
But if the above Proxy needed to be registered separately for each user, you'd need to make the name unique, which you might do like this:
public class UserProxy extends Proxy
{
public static const NAME:String = 'UserProxy';
public function UserProxy( user:User )
{
super ( NAME+"/"+user.id, user );
}
}
-=Cliff>