GWT 2.3: Activities and Automatic Event Deregistration

39 views
Skip to first unread message

objectuser

unread,
Aug 17, 2011, 8:23:35 AM8/17/11
to google-we...@googlegroups.com
Handlers added to the eventBus passed to the Activity.start method are not automatically deregistered for me.  I'm guessing it's my code, since I don't see much recent discussion about this.  I don't throw away my activities each time, so maybe that's my issue.  But reading the documentation makes me think this should work.

From the javadoc of start:
Any handlers attached to the provided event bus will be de-registered when the activity is stopped, so activities will rarely need to hold on to the HandlerRegistrationinstances returned by EventBus.addHandler(com.google.gwt.event.shared.GwtEvent.Type, H).
However, if I have:

    @Override
    public void start(AcceptsOneWidget panel, EventBus eventBus) {
        panel.setWidget(view);

        placeChangeRegistration = eventBus.addHandler(PlaceChangeEvent.TYPE, new PlaceChangeEvent.Handler() { 
            @Override
            public void onPlaceChange(PlaceChangeEvent event) {
                doSomething();
            }
        });
    }

The handler is triggered even after onStop is called in my activity.  I also tried holding on to the registration (as above) and removing it in onStop and the handler is still called.

Does anyone have an idea of what I might be doing wrong?

Thanks.

objectuser

unread,
Aug 17, 2011, 9:06:41 AM8/17/11
to google-we...@googlegroups.com
I might understand this better.  It seems like the event registration is still fired in the event cycle that causes the onStop method to be called.  After that, subsequent events don't activate that registration.  Confirmation is welcome. :)
Reply all
Reply to author
Forward
0 new messages