PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: marks416 on October 13, 2008, 02:43:45



Title: Question for facade class?
Post by: marks416 on October 13, 2008, 02:43:45
Hi,

I am new for pureMVC, I knwo facade class have the following methods

removeMediator
removeCommand   
removeProxy

I wonder when we need to use the methods and the purpose to use them( for save monory,garbage collection or others).

Thanks for your help.

Mark


Title: Re: Question for facade class?
Post by: puremvc on October 13, 2008, 03:05:08
Precisely. Things should be generally be removed when they are no longer needed. Some Mediators, Proxies and Commands stay registered throughout the entire running application, because that is their lifecycle.

But, for instance, you might have a Flex component that has 3 states. And when it changes states, you want different mediators to be registered for the sub components that get added in the new state, and to remove the mediators for components from the previous state which are removed.

If you do not remove the mediator, then even though Flex has removed the component from the view, the mediator still has a reference to the component and it will not be garbage collected. In fact inside an app I'm refactoring for a client at the moment, that very problem leads to a video continuing to play and its sound to be heard even when you log out of the application and the video component has been removed from the display and replaced by a Login box.

-=Cliff>