When is it a good time to remove elements (Proxy,Mediator,Commands) from the facade? Would it be "better" to leave all the assets available rather than subscribing/unsubscribing?
IMO, a good time to remove the PureMVC actors is when navigating away or switching away from the view doesn't automatically destroy them.
Suppose, you have an application in which the functionality is implemented as modules and clicking on the NEXT or the PREVIOUS button unloads the current module and loads the next one.In this case, the only thing you need to destroy is the Facade. There are two reasons for this:
- Destroying the facade automatically does away with the registered Proxies, Mediators and Commands.
- Destruction is required since you would want a new core or a new Facade instance rather than the old one which preserves the previous application state
The only time I've felt a need to destroy mediators is when my application is structured as multiple stacked views [implemented as ViewStack in Flex] which don't get destroyed when the user switches views but merely are hidden from the user. In this case, keeping the old Mediator with it's event listeners registered with the view can have unforeseen consequences like hard-to-find bugs.
I never bother with Commands and Proxies since I almost always register them at the Facade level and since I make sure I destroy the Facade, those two are automatically taken care of.
-sasuke