tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/11504-making-an-interface-to-deal-with-injectsRobotlegs: Discussion 2014-07-21T14:01:29Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/338131752014-07-17T17:06:54Z2014-07-17T17:08:12ZMaking an interface to deal with injects<div><p>Then again, after trying to implement a class inheriting
injections from another class, I realize that I have no idea what
the config would look like.</p>
<p>EDIT: The answer? It doesn't change the config at all! So, yes,
this method does actually work.</p></div>zmaldonadotag:robotlegs.tenderapp.com,2009-10-18:Comment/338131752014-07-18T08:43:05Z2014-07-18T08:43:05ZMaking an interface to deal with injects<div><blockquote>
<p>I'm wondering what the best way of just cleaning up code is when
it comes to injections.</p>
</blockquote>
<p>As you well know by now, mediators are created when their views
are added to the stage and destroyed when the views leave the
stage, provided the autoRemove was set to true (which is the
default) when you mapped a view to a mediator.<br>
The destroy method of a mediator is a convenient place to do some
clean up work.<br>
Event listeners added through addContextListener or addViewListener
are automatically removed when the mediator is destroyed.</p>
<p>That's not the case for signals or for events listeners added
directly to views and/or their subcomponents.<br>
They keep mediators alive, thus causing garbage collection issues.
You need to override the destroy method and remove such listeners
manually, if you wish to spare yourself a lot of unnecessary
debugging and headaches;)</p>
<pre>
<code>override public function destroy():void
{
someSignal.remove(someListener);
super.destroy();
}</code>
</pre></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/338131752014-07-18T20:50:58Z2014-07-18T20:50:58ZMaking an interface to deal with injects<div><p>Oh wow, thanks! I didn't even think that signals wouldn't get
garbage collected. Thanks, Ondina!</p></div>zmaldonadotag:robotlegs.tenderapp.com,2009-10-18:Comment/338131752014-07-21T14:01:27Z2014-07-21T14:01:27ZMaking an interface to deal with injects<div><p>You're welcome!</p></div>Ondina D.F.