Using Closure Library, you can give any object the ability to dispatch events extending goog.events.EventTarget
. Is this currently possible using Dart libraries?
I imagine it would look like this:
#import('dart:html');
class Foo implements EventTarget {
Events get on() {
// ???
}
}
main() {
Foo foo = new Foo();
// Subscribe to the event.
foo.on['bar'].add((Event event) => print('bar!'));
// Dispatch the event.
foo.on['bar'].dispatch(new Event('bar'));
}
Am I on the right track?
Edit Thanks to Lars Tackmann, a working draft is here: http://try.dartlang.org/s/f6wk