I want to remove a GWT event handler the first time I receive an event. I also want to avoid polluting my class with tracking registration objects that aren't really necessary. I currently have it coded as:
final HandlerRegistration[] registrationRef = new HandlerRegistration[1]; registrationRef[0] = dialog.addFooHandler(new FooHandler() { public void onFoo(FooEvent event) { HandlerRegistration removeMe = registrationRef[0]; if(removeMe != null) { removeMe.removeHandler(); } // do stuff here } });
but the use of registrationRef makes the code less readable. Is there a better way to do this without adding variables to my class?