Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Unified Diff: pkg/polymer/lib/src/events.dart

Issue 347463002: avoid addEventListener in Polymer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/events.dart
diff --git a/pkg/polymer/lib/src/events.dart b/pkg/polymer/lib/src/events.dart
index 2ca037c2bb8632598c8c7e3852b81f4bafb7f281..9e76111ef0f84ceb826671173a5a1ac93ce16de8 100644
--- a/pkg/polymer/lib/src/events.dart
+++ b/pkg/polymer/lib/src/events.dart
@@ -82,22 +82,20 @@ abstract class PolymerEventBindings {
return (model, node, oneTime) {
var handler = getEventHandler(null, node, path);
- node.addEventListener(eventType, handler);
+ var sub = node.on[eventType].listen(handler);
if (oneTime) return null;
- return new _EventBindable(node, eventType, handler, path);
+ return new _EventBindable(sub, path);
};
}
}
class _EventBindable extends Bindable {
- final Node _node;
- final String _eventType;
- final Function _handler;
+ final StreamSubscription _sub;
final String _path;
- _EventBindable(this._node, this._eventType, this._handler, this._path);
+ _EventBindable(this._sub, this._path);
// TODO(rafaelw): This is really pointless work. Aside from the cost
// of these allocations, NodeBind is going to setAttribute back to its
@@ -107,7 +105,12 @@ class _EventBindable extends Bindable {
open(callback) => value;
- void close() => _node.removeEventListener(_eventType, _handler);
+ void close() {
+ if (_sub != null) {
+ _sub.cancel();
+ _sub = null;
+ }
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698