On 18 juin, 18:01, Ian Bambury <ianbamb...@gmail.com> wrote:
> 2009/6/12 Thomas Broyer <t.bro...@gmail.com>
>
> > > 1- What is missing here is when would the Client UI typically
> > > subscribe/unsubscribe from the event bus.  If this were a desktop
> > > application I would simply use weak reference so I would not have to
> > > unsubscribe my UI manually to prevent a memory leak.
>
> > As with any event, I'd subscribe in the onLoad and unsubscribe in the
> > onUnload (would be even better if there was a destructor, so that even
> > when not attached to the DOM, your widget could receive events and
> > enter a "dirty" state, so that when it is attached again to the DOM it
> > knows if it has to refresh or not)
>
> I didn't understand that bit.
>
> The presenter needs to subscribe but is just a class and doesn't have an
> onUnload method.

Right!
(couldn't we make the presenters all have onLoad/onUnload methods to
be called by other components when they make use of a presenter; in
the Google I/O slides, the presenter as a method go(Widget) which is
almost equivalent to Widget::onLoad, what happens when you don't need
the component any more, it must have some other method that would be
similar to Widget::onUnload, no? of course, it would mean that
developers have to make sure they call that onUnload method when they
no longer need a component; some asserts in a window.onunload could
make it easier to discover those leaks: the eventbus shouldn't have
any subscriber left. Did I say I'm not really used to MVC/MVP?)

> Even if you make it a widget, having subscribed, since the
> eventbus has a reference to it, you won't get an unload.

This I don't understand, onUnload is called by the parent widget
(through onDetach) when you remove its child (and it thus is detached
from the DOM). Whether the eventbus has a reference to the widget is
orthogonal.

> Or am I missing something obvious here.

I'd rather say it's probably me ;-)

--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to