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

Unified Diff: tools/dom/src/Isolates.dart

Issue 12217124: Removing deprecated events syntax. (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:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/dom/scripts/systemhtml.py ('k') | tools/dom/templates/html/impl/impl_EventTarget.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/src/Isolates.dart
diff --git a/tools/dom/src/Isolates.dart b/tools/dom/src/Isolates.dart
index 3e4f507e5ac8d12d23cc97339656e0037655b5b3..467d998d3db5a79a8caf9e9ba30545e2ba1c5b3b 100644
--- a/tools/dom/src/Isolates.dart
+++ b/tools/dom/src/Isolates.dart
@@ -99,12 +99,10 @@ class _RemoteSendPortSync implements SendPortSync {
// TODO(vsm): Set this up set once, on the first call.
var source = '$target-result';
var result = null;
- var listener = (Event e) {
+ window.on[source].first.then((Event e) {
result = json.parse(_getPortSyncEventData(e));
- };
- window.on[source].add(listener);
+ });
_dispatchEvent(target, [source, message]);
- window.on[source].remove(listener);
return result;
}
@@ -159,7 +157,7 @@ class ReceivePortSync {
num _portId;
Function _callback;
- EventListener _listener;
+ StreamSubscription _portSubscription;
ReceivePortSync() {
if (_portIdCount == null) {
@@ -184,21 +182,20 @@ class ReceivePortSync {
void receive(callback(var message)) {
_callback = callback;
- if (_listener == null) {
- _listener = (Event e) {
+ if (_portSubscription == null) {
+ _portSubscription = window.on[_listenerName].listen((Event e) {
var data = json.parse(_getPortSyncEventData(e));
var replyTo = data[0];
var message = _deserialize(data[1]);
var result = _callback(message);
_dispatchEvent(replyTo, _serialize(result));
- };
- window.on[_listenerName].add(_listener);
+ });
}
}
void close() {
_portMap.remove(_portId);
- if (_listener != null) window.on[_listenerName].remove(_listener);
+ if (_portSubscription != null) _portSubscription.cancel();
}
SendPortSync toSendPort() {
« no previous file with comments | « tools/dom/scripts/systemhtml.py ('k') | tools/dom/templates/html/impl/impl_EventTarget.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698