Many thanks for the replies. 

Now I see how can this be done with onLoad(), and thanks for cofirmation 
about it beeing reference related. 

Thomas why is a static Event bus bad ?
I had all my "MyApp.java" non static a while ago, with all the 
model/params/loggers/event bus and other things inside. But as the app 
grows it seems to me a hassle to force all my classes to have the "myApp" 
attribute, so I just made MyApp static. I guess I'm completly wrong ? :)
Note : I'm not using any standard MVP but a home-made "Model - UI" and no 
GIN either.

Le lundi 4 mars 2013 10:57:26 UTC+1, Thomas Broyer a écrit :
>
>
>
> On Monday, March 4, 2013 10:31:21 AM UTC+1, Martones wrote:
>>
>> 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() {
>>
>
> From now on, the event bus has a reference on an UpdateDataEventHandler, 
> which itself –being an anonymous, hence non-static, class– has a reference 
> on the TestWidget, so the event bus has a reference on the widget.
>
> When you want to "destroy" the widget, you then have to remove that 
> handler.
> It's generally a good idea to register/unregister from within the 
> onLoad/onUnload methods of the widget, but if you want the widget to 
> receive events even when not attached, then you have to provide an explicit 
> "tear down" method so it unregisters all handlers from the event bus.
>
> (btw: oh wow, a static event bus?)
>

-- 
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