Re: Event disposals
On 22 jan, 16:57, shahid <shahidza...@gmail.com> wrote:
> I am a little confused about event disposal in GWT. Should I always
> keep a reference to all HandlerRegistration objects whenever I attach
> a handler to something (e.g. image, links etc.) and then dispose them
> using .removeHandle upon widget detach ? Will not doing so end up in
> memory leak ? Or do the events get disposed of upon Widget detach
> automatically ?
If you attach your handlers in onAttach unconditionally,then you
should really remove them in onDetach. But you can also do the
following:
public void onAttach() {
if (isOrWasAttached()) {
// attach handlers
}
super.onAttach();
}
and then just simply do nothing in onDetach.
Or you can even attach your handlers before onAttach (e.g. on the
constructor), and never explicitly detach them.
GWT will take care of the rest, and particularly that there's no
memory leak.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home