Old mediator is not removed (Flex)

bildeyko's Avatar

bildeyko

22 Nov, 2013 03:11 PM

Hello!

I have 2 views: "FirstView" and "SecondView", 2 mediators: "FirstMediator" and "SecondMediator".
Then I change views with navigator.popToFirstView(), starts a new screen, a new mediator is initialized, but the old mediator is not removed and listens to events that are sent to a new screen. Old mediator intercepts the event.
I do not know the cause of the problem.

If you need more information, tell me.

  1. Support Staff 1 Posted by Ondina D.F. on 26 Nov, 2013 12:07 PM

    Ondina D.F.'s Avatar

    Hello,

    I'm sorry for the late response, but your post got stuck into forum's spam filter, and I haven't notice that until today.

    It seems like something is keeping your view(s) alive. The mediators are destroyed when their views leave the stage and are garbage collected (null). References to views keep them alive. There are several possible causes for this. Some things to check:

    [1] Clean up the views when they get removed from stage:

    • remove event listeners

    • remove child components

    • remove external references

    • remove effects references, tweening listeners, functions references

    • remove bindings

    • be aware of styles, item renderers that might keep the view alive

    • setting buttonMode=true, setting focusEnabled=true can also keep a view from being gc-ed, so set them to false when the view is removed from stage

    [2] Allow Mediators to be destroyed:

    If views are mediated, make sure to remove all registered events and signals listeners. If you're using addViewListener to add event listeners, they will be automatically removed when mediator's destroy() runs. But, if you add listeners directly to the view or its subcomponents, you have to manually remove them inside your destroy() method. If you're using Signals, destroy() is also the place were you should -manually- remove the listeners. If you forget to do so, the Signals will keep your view and/or mediator alive!!!

    I'll attach a very simple mobile app. If you're using something like the Flash Profiler, you can see that the views get garbage collected and their mediators as well.
    If you can't resolve the issue, you might want attaching a bare-bone project reproducing the problems and I'll take a look at it. Or, you can modify the attached project to reflect your settings and let me see it.

    hth
    Ondina

  2. Ondina D.F. closed this discussion on 23 Dec, 2013 09:26 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac