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: how does removeMediator works?  (Read 9306 times)
Arno
Newbie
*
Posts: 5


View Profile Email
« on: July 23, 2009, 07:25:15 »

I have different view components with there own mediator. I'm stuck at the point that I remove a view. I have a couple of questions about this:

1) do you remove the viewcomponent or the mediator first?

2) Can you just remove the mediator of do you also have to remove eventlisteners before you remove it? Because I tried to remove a viewcomponent and then the mediator. After that I get a error from the mediator on a addeventlistener. What is strange because if i check with facade.hasMediator he returns false for that mediator

3) I red somewhere about a destroy() function where do I put it and how does it look like? Or beter is there an example? I coundn't find one

Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #1 on: July 23, 2009, 08:00:16 »

Remove the mediator first, then in the mediators onRemove() function remove the view component.

example
:
override public function onRemove():void {
    viewComponent.parent.removeChild(viewComponent);
    // OR send a note to the parent objects mediator to remove
    sendNotification(REMOVE_CHILD, viewComponent);
}

You can also remove any relevant event listeners there as well.
Logged
Arno
Newbie
*
Posts: 5


View Profile Email
« Reply #2 on: July 24, 2009, 12:37:32 »

thank you very much. It is working!
Logged
Pages: [1]
Print