Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Example of when is necessary to remove elements?  (Read 2729 times)
Helmut Granda
Full Member
***
Posts: 47

Flash Developer.


View Profile WWW Email
« on: October 05, 2009, 11:01:41 »

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?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: October 06, 2009, 06:01:12 »

The only time I go to the trouble to remove Proxies, Mediators and Command mappings is if there is a danger they may be retriggered with bad consequences. Not to often really. For instance, if the only place the STARTUP notification is sent is from the concrete facade's startup method, and that's only called from the application's creationComplete, then it's safe to say it'll never be called again. So sure, I could remove it but leaving it in place wouldn't hurt anything either and would require less code.

-=Cliff>
Logged
sasuke
Full Member
***
Posts: 29


View Profile Email
« Reply #2 on: October 21, 2009, 02:09:10 »

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
Logged
Pages: [1]
Print