PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: intonarumori on October 06, 2008, 03:02:10



Title: Removing mediators and views
Post by: intonarumori on October 06, 2008, 03:02:10
Hello, I'm just getting into pureMVC and it worked superb so far.
The only thing I miss is some example on removing mediators and views.
Let's say we have 50-100 view some of them with subviews maybe with some PV3D on it and so on, so if the user is browsing the application at some point memory starts taking too much because of none of the mediators gets destroyed and all of them contain references to the viewcomponent he mediates.

How would you approach this situation?
Where should I place removemediator's, how to handle references to them etc.

I've searched the forum and at some point you discusses that it isn't a good idea to remove mediators. Just leave them where they are. Could you explain it a bit more?


Thanks, Daniel


Title: Re: Removing mediators and views
Post by: puremvc on October 06, 2008, 06:24:24
When a view component is removed from the view, listen for the REMOVED event in the mediator and have the Mediator remove itself with facade.removeMediator(this.getMediatorName());

-=Cliff>


Title: Re: Removing mediators and views
Post by: JJfutbol on October 06, 2008, 05:37:38
@Cliff,

Curious about this since I've wondered the same about where to remove mediators. I have a Flex PopUp or an AIR Window each with its own mediator. I have a command create and display it so its easily created from different inputs (buttons, keyboard shortcuts, etc.). Should I have another command remove the mediator for those windows too? Or is it ok to let the mediator remove itself from the framework?


Title: Re: Removing mediators and views
Post by: puremvc on October 06, 2008, 08:53:20
As of the last release, its safe to have the mediator remove itself

Before that, although the practice was accepted, it would cause the very next observer in the list (if there was one) not to be notified. This is no longer a problem. 

-=Cliff>