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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Side-by-side diff isn't available for this file because of its large size.
Issue 12220003: Adding event delegation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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:
Download patch
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 9d5bddf87dbc07514a03bd5efe601b28e087f041..84c035fae88d61ca3390860cd830a636186d1944 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -30560,6 +30560,42 @@ class EventStreamProvider<T extends Event> {
Stream<T> forTarget(EventTarget e, {bool useCapture: false}) {
return new _EventStream(e, _eventType, useCapture);
}
+
+ /**
+ * Gets a single event [Stream] which is the combinations of event streams
+ * for this event for each target.
+ *
+ * See also:
+ *
+ * * [forTarget]
+ */
+ Stream<T> forTargets(List<EventTarget> targets, {bool useCapture: false}) {
+ // Clone so modifications to the list don't affect this.
+ targets = new List.from(targets);
+
+ // Keep track of subscriptions so we unsubscribe from all when the stream
+ // we return is unsubscribed.
+ var subscriptions = [];
+ var controller;
+ controller = new StreamController<T>(onSubscriptionStateChange: () {
+ if (controller.hasSubscribers) {
+ assert(subscriptions.isEmpty);
+ for (var target in targets) {
+ subscriptions.add(forTarget(target, useCapture: useCapture).listen(
+ (e) {
+ controller.add(e);
+ }));
+ }
+ } else {
+ assert(subscriptions.length == targets.length);
+ for (var subscription in subscriptions) {
+ subscription.cancel();
+ }
+ subscriptions.clear();
+ }
+ });
+ return controller.stream;
+ }
}
/**
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698