use of com.google.gwt.event.logical.shared.AttachEvent.Handler in project rstudio by rstudio.
the class EventBus method addHandler.
/**
* Similar to 2-arg form of addHandler, but automatically removes handler
* when the HasAttachHandlers object detaches.
*
* If the HasAttachHandlers object detaches and reattaches, the handler
* will NOT automatically resubscribe.
*/
public <H extends EventHandler> void addHandler(HasAttachHandlers removeWhenDetached, Type<H> type, H handler) {
final HandlerRegistration reg = addHandler(type, handler);
removeWhenDetached.addAttachHandler(new Handler() {
@Override
public void onAttachOrDetach(AttachEvent event) {
if (!event.isAttached())
reg.removeHandler();
}
});
}
Aggregations