Hey everyone,

I noticed that my widget still listens to events from EventBus event after 
I remove them from the DOM and after I clear all my references to them. I 
was thinking if this was because of the EventBus bus handler the widget 
has. Or I am missing something !

Anyway here is a simplified test illustrating this. The Event i'm using is 
a basic custom event and the Window.alert is there just to make sure the 
event is received.

class TestWidget extends Composite {
public TestWidget(final int id) {
// register to event 
EVENT_BUS.addHandler(UpdateDataEvent.TYPE, new UpdateDataEventHandler() {
public void onUpdate(UpdateDataEvent event) {
logger.log("n°" + id + " living");
}
});

initWidget(new HTML("TestWidget #" + id));
}
}

// add test widgets to DOM
TestWidget t1 = new TestWidget(1);
TestWidget t2 = new TestWidget(2);
RootaPanel.get().add(t1);
RootaPanel.get().add(t2);

// fire event
EVENT_BUS.fireEvent(new UpdateDataEvent());
// logs as expected : #1 and #2

// little break
Window.alert("Break");

// remove one widget and force the reference to null
t1.removeFromParent();
t1 = null;

// fire event
EVENT_BUS.fireEvent(new UpdateDataEvent());
// still logs #1 and #2

Any heads-up ?

Many thanks, 

Ludovit

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to