PopUpsExcellent question! I've found it very helpful to have an AbstractMediator that will retrieve any common Proxies required by all mediators for such things like Configuration, Identity, sometimes even a specific entity, etc.
Since I've had projects that require a few PopUps I've found it handy to create an AbstractPopUpMediator which extends the AbstractMediator. All the AbstractPopUpMediator does is define a private getter for the viewComponent property called "popUp" where its cast as an IFlexDisplayObject. On registration I add 2 event listeners for when the popUp is closed or when you mouse down on the outside area of a popup.
In this case I have that code in a base class but when I first did this I would always have it in the PopUp's actual mediator. Either one works well just depends on preference. I had asked awhile back and you were kind enough to respond Cliff about Mediators removing them self from the Facade so in this case I have the popUp Mediator do that which I find simple and easy. I haven't had a need for having that code in a command but a real great need for opening and determining how one is opened with a command.
WindowsFor windows in AIR I have the same approach regarding a command to open one. I've had a real need for this since I have logic that has to figure out if the window for a VO is already open, if it is just activate it (bring it to the front and set focus) otherwise one needs to be created. In this case the command is called OpenIdeaEditorCommand and my mx:Window component is called IdeaEditor (think exactly like creating a new email with Apple Mail).
My case is that what makes the component unique is the IdeaVO. I use Flex's UIDUtil class and call the getUID(obj) method passing in an IdeaVO instance to make sure I have a unique id for each instance. This is how I register mediators since I use that UID as a name! I check if their is a mediator registered with that name and if there is I know a window is already open (in this case for an existing idea that is being edited) so I send a ACTIVATE_IDEA_EDITOR notification which that Mediator responds too by calling the viewComponent's activate() method.
If the mediator is not registered I know I need to create a new IdeaEditor so that is done in the command as well as creating and registering the new mediator. All event handlers are taken care of within the mediator, not the command! So if you close the window the mediator listens for a close event so it can remove itself from the Facade. Hot!
![:)](http://forums.puremvc.org/Smileys/default/xsmiley.gif.pagespeed.ic.R8GFI-pF6f.png)
Cliff, I showed this at the set of PureMVC presentations at MAX since it is an AIR client I built using PureMVC.
As I've mentioned to you I'd like to do a series of short presentations/recordings for the PureMVC site since I think I've really nailed the Mediator-Component relationship and have some neat examples on how best to use Commands. Also some advice on how to determine what should be an individual component, when to know to use a command, etc.