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.