- Any opinions on naming? Currently the events are exposed as onEventName, but it's often common to use this naming style for virtual methods. Using just eventName has a number of conflicts with members. We aren't entirely thrilled with onEventName.
How do i remove an event listener? Does the "listen" method return some kind of handle?
The way it works today is really bad. Most people would assume that ...
element.on.click.add(onClickHandler);
element.on.click.remove(onClickHandler);
onClickHandler(e) { }
Examples of old vs new syntax:Listening to an eventOld:element.on.click.add((e) {});New:element.onClick.listen((e) {});
Element.clickEventProvider.provideEvent(document.body);
... and then steal the "Event" suffix naming convention for the Streams themselves:el.clickEvent.listen(f);
"Old" API is elegant, simple and is a light way to listen an event on a DOM element.
The new way doesn't respect the OO philosophy by using a "dirty" global static method to listen all DOM events, it's more verbose and not intuitive.
How I can emit custom events when old API with on[eventName].dispatch will be removed?
How I can emit custom events when old API with on[eventName].dispatch will be removed?
query('#btn').on['clickMe'].dispatch(new CustomEvent('clickMe', true, true, new ClickMeEventArgs("value1", "value2")));
--
StreamController<CustomEvent> sc = new StreamController.multiSubscription();
sc.listen((CustomEvent event) {
print("listener #1");
});
sc.listen((CustomEvent event) {
print("listener #2");
});
sc.add(new CustomEvent('clickMe', true, true, new ClickMeEventArgs("value1","value2")));
--
--
Element.clickEvent.forTarget(element, useCapture: true).listen((e) {
});
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
Streams are indeed not really sub-classable but from the API complexity standpoint having separate members for capture is too much. IMHO desiring API extensions such as 'matches' is perfectly reasonable- an ideal scenario for extension methods!The mere presence of those members has a non-trivial effect on dart2js compilation size, I'd be hesitant to double them.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
BTW, you mentioned dart2js generated code size. Isn't tree shaking supposed to remove unused fields? Just out of curiosity.