He all,

Please a bit of advice on the following?

In Java you can use the WeakReference object to work with so called
weak Listeners. More details on this can be found here for example:
http://www.javalobby.org/java/forums/t19468.html
or: http://www.ibm.com/developerworks/java/library/j-jtp11225/

I would love to do something similar but WeakReference isn't supported
in GWT. How do others deal with it ?

My problem: Suppose the following:
ViewCategory is created and adds a property listener to a global Model
to listen to Member name changes.
The view isn't needed anymore and as such his instance reference made
null in the controller where it's used.
The next time this view is needed, a new ViewCategory instance is
created, a listener is registered and the view is shown. We assume
that the old instance was garbage collected -> wrong assumption :(
Suppose that I forget to unregister the listener -> memory leak.....
The model keeps an association to the nested listener in the
ViewCategory instance such that this object and his nested objects
stay in memory.

Ofcourse you then say:" then clean this properly"... Yep... I do my
best, but in a complex situation with many requirements and things
going from left to right, it can happen that this is forgotten.

What would be nice:  weak listeners, like Swing has, such that when he
ViewCategory isn't associated anymore, it's removed and as such also
his listener from the global model.

How do I realize something like this ?

-- Ed
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to