I have a question on the weak references when adding a listener like this:

 

btnSave.addEventListener(MouseEvent.CLICK, onBtnSaveClick, false, 0, true);

 

I have found this approach with weak reference as an advise somewhere, but I
would like to understand what happens really.

 

If we add a listener specifying useWeakReference = true as in the example
above, does this mean that the garbage collection might remove unexpectedly
the event listener and the mouse event handling to stop working?

 

When using weak reference for the event listener, is it needed to explicitly
remove the event listener at some point in time?

 

In general - what is the best practice in this regard?

 

Kind Regards,

Nikolay

 

 

Reply via email to