Optimise of Event subsystem.
Remove EventHandler and all extended classes. Remove EventHandlerAdapter and all extended classes. Invite typedef solution like that ClickEvent class:
part of dart_web_toolkit_event;
typedef void HandleClick(ClickEvent event);
/**
-
Represents a native click event. */ class ClickEvent extends MouseEvent {
/**
- The event type. */ static DomEventType<HandleClick> TYPE = new DomEventType<HandleClick>(BrowserEvents.CLICK, new ClickEvent());
DomEventType<HandleClick> getAssociatedType() { return TYPE; }
ClickEvent();
void dispatch(HandleClick handler) { handler(this); } }
Make changes like in FocusWidget /**
- Adds a {@link ClickEvent} handler. *
- @param handler the click handler
- @return {@link HandlerRegistration} used to remove this handler */ HandlerRegistration addClickHandler(HandleClick handler) { return addDomHandler(handler, ClickEvent.TYPE); }
HasClickHandler: part of dart_web_toolkit_event;
/**
-
A widget that implements this interface provides registration for
-
{@link ClickHandler} instances. */ abstract class HasClickHandlers implements HasHandlers {
/**
- Adds a {@link ClickEvent} handler. *
- @param handler the click handler
- @return {@link HandlerRegistration} used to remove this handler */ HandlerRegistration addClickHandler(HandleClick handler); }
Widget:
/**
- Adds a native event handler to the widget and sinks the corresponding
- native event. If you do not want to sink the native event, use the generic
- addHandler method instead. *
- @param <H> the type of handler to add
- @param type the event key
- @param handler the handler
- @return {@link HandlerRegistration} used to remove the handler */ HandlerRegistration addDomHandler(handler, DomEventType type) { assert (handler != null); // : "handler must not be null"; assert (type != null); // : "type must not be null"; int typeInt = IEvent.getTypeInt(type.eventName); if (typeInt == -1) { sinkBitlessEvent(type.eventName); } else { sinkEvents(typeInt); } return ensureHandlers().addHandler(type, handler); }
Event System rework should be "higher in the list" (earlier Milestone) as its a "very" breaking change and makes the code easier to read and write!
now:
refreshButton.addClickHandler(new ClickHandlerAdapter((ClickEvent event) {
}));
should be: refreshButton.onClick.listen((ClickEvent event) { });
Hi Manuel,
I agree with you, it might be done earlier.
Sergey.
On 11 July 2013 16:52, Manuel [email protected] wrote:
Event System rework should be "higher in the list" (earlier Milestone) as its a "very" breaking change and makes the code easier to read and write!
now: refreshButton.addClickHandler(new ClickHandlerAdapter((ClickEvent event) {
}));
should be: refreshButton.onClick.listen((ClickEvent event) { });
— Reply to this email directly or view it on GitHubhttps://github.com/akserg/dart_web_toolkit/issues/85#issuecomment-20816946 .