Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static interface MyHandler extends EventHandler {
- void onEvent(MyEvent event);
- }
- public static class MyEvent extends GwtEvent<MyHandler> {
- private static Type<MyHandler> type = new Type<>();
- @Override
- public Type<MyHandler> getAssociatedType() {
- return type;
- }
- @Override
- protected void dispatch(MyHandler handler) {
- handler.onEvent(this);
- }
- }
- protected final EventBus bus = new SimpleEventBus();
- public MyClass withCellSelectHandler(MyHandler handler) {
- bus.addHandler(MyEvent.type, handler);
- return this;
- }
- // somewhere in MyClass:
- bus.fireEvent(new MyEvent())
- }
- // usage:
- new MyClass().withCellSelectHandler(event -> GWT.log("Hey"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement