Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise of Event subsystem. #85

Open
akserg opened this issue May 3, 2013 · 2 comments
Open

Optimise of Event subsystem. #85

akserg opened this issue May 3, 2013 · 2 comments
Assignees
Milestone

Comments

@akserg
Copy link
Owner

akserg commented May 3, 2013

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 TYPE = new DomEventType(BrowserEvents.CLICK, new ClickEvent());

    DomEventType 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 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);
    }
@ghost ghost assigned akserg May 3, 2013
@Bluenuance
Copy link

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) {
});

@akserg
Copy link
Owner Author

akserg commented Jul 11, 2013

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//issues/85#issuecomment-20816946
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants