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: Removing mediators and views  (Read 7077 times)
intonarumori
Newbie
*
Posts: 1


View Profile Email
« 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
« Last Edit: October 06, 2008, 03:04:06 by intonarumori » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>
Logged
JJfutbol
Sr. Member
****
Posts: 53


View Profile WWW Email
« Reply #2 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?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 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>
Logged
Pages: [1]
Print