Mediators Garbage collection issue
I am facing a problem regarding garbage collection of Mediator
.
I have two different states for a component which has Two sub
components having mapped mediators. When i change the state from
first to second and navigate back to first state , new instance of
sub-component which is in first state is created along with its
mediator, but what i observed is that there are two mediators
working for same view.The number of mediators keeps on adding as i
keep on toggling between two states.I have also kept weakreferences
true for all listeners. Can Anyone help me in this.
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
Support Staff 1 Posted by Ondina D.F. on Jan 11, 2012 @ 09:58 AM
Hi PJ,
mediatorMap.mapView(SomeView, SomeMediator, null, true, true);
The last two parameters autoCreate and autoRemove are boolean switches that provide convenient automatic mediator management, by default set to true.
If you set autoRemove to false, the Mediator won’t be removed after the View has been removed from the display list.
Try this and tell if it solved your issue.
Ondina
2 Posted by PJ on Jan 11, 2012 @ 10:48 AM
Ondina,
Thanks for your suggestion , I tried it but still there is no success . I am still observing multiple mediators acting for single view events.
Support Staff 3 Posted by Ondina D.F. on Jan 11, 2012 @ 10:54 AM
Could you attach a stripped out example exhibiting the issue or paste some relevant code. I will take a look at it.
Support Staff 4 Posted by Ondina D.F. on Jan 11, 2012 @ 01:37 PM
What’s happening in the onRegister() method of your mediators? Can you show us at least that fragment of your code? Are you doing more than just adding events listeners?
Support Staff 5 Posted by Ondina D.F. on Jan 11, 2012 @ 04:52 PM
I was in the middle of building a simple flex application using states that I intended to let you see, but then I spotted Shaun’s example : FlexyStates.fxp
http://knowledge.robotlegs.org/discussions/questions/114-best-use-o...
It may help you.
6 Posted by PJ on Jan 13, 2012 @ 04:45 PM
I got solution for it,
I mediator i was applying listeners to uicomponents by addEventListener . Rather than doing that i am now using eventMap.mapListener to addlisteners to view children in mediators and override method:
This is working fine.Attaching sample App which illustrates the diffrence
7 Posted by Stray on Jan 13, 2012 @ 04:52 PM
Hi PJ,
eventMap.unmapListeners is done by the mediator already, so you don't need to override that function - just as long as you use eventMap.mapListener to the view children, it'll get cleaned up automatically.
I'm glad you fixed it,
Stray
Ondina D.F. closed this discussion on Feb 10, 2012 @ 11:55 AM.