Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It's always a good idea to remove your listeners explicitly when you no longer need them, yeah, and the way you're doing it is fine. It might seem a little verbose, but it's still good practice, and it keeps you in the habit of knowing where your listeners are, since not knowing leads so often to leaks and unexpected behavior.</p> <p>As for useWeakReference, I almost always use it myself, in addition to removing unneeded listeners. For me, it's become the rule rather than the exception. If you had to choose one, though, remove your listeners explicitly. Personally, though, I do both.</p> <p>In fact, the I've found the number of occasions in which it'd be best to leave useWeakReference false, since doing so will prevent objects from being garbage collected, is especially rare. Indeed, before I learned what that argument was for (<a href="http://chris.enunciato.org/entry.aspx?id=542" rel="nofollow noreferrer">blog post here</a>), I spent a ton of time scratching my head after getting runtime exceptions stemming from the Flex framework making calls on components I was sure I'd removed from the display list. </p> <p>Deepa Subramaniam mentioned it obliquely in <a href="http://tv.adobe.com/#vi+f15384v1002" rel="nofollow noreferrer">her component-model talk</a> at last year's MAX conference (an excellent talk well worth checking out); I believe the way she put it was something like, "I don't know why the Flash player team chose to make false the default rather than true, but 99% of the time, you're going to want to set that value to true."</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload