OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library pub.load_transformers; | 5 library pub.load_transformers; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 | 10 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 Map _serializeTransformerGroup(TransformerGroup group) { | 207 Map _serializeTransformerGroup(TransformerGroup group) { |
208 return { | 208 return { |
209 'type': 'TransformerGroup', | 209 'type': 'TransformerGroup', |
210 'toString': group.toString(), | 210 'toString': group.toString(), |
211 'phases': group.phases.map((phase) { | 211 'phases': group.phases.map((phase) { |
212 return phase.map(_serializeTransformerOrGroup).toList(); | 212 return phase.map(_serializeTransformerOrGroup).toList(); |
213 }).toList() | 213 }).toList() |
214 }; | 214 }; |
215 } | 215 } |
216 | 216 |
217 /// When the input receives a 'done' as data-event, transforms it to a | 217 /// When the input receives a 'done' as data-event, transforms it to a |
218 /// done event and cancels the subscription. | 218 /// done event and cancels the subscription. |
219 StreamSubscription doneTransformer(Stream input, bool cancelOnError) { | 219 StreamSubscription doneTransformer(Stream input, bool cancelOnError) { |
220 var subscription; | 220 var subscription; |
221 var transformed = input.transform(new StreamTransformer.fromHandlers( | 221 var transformed = input.transform(new StreamTransformer.fromHandlers( |
222 handleData: (data, sink) { | 222 handleData: (data, sink) { |
223 if (data == 'done') { | 223 if (data == 'done') { |
224 sink.close(); | 224 sink.close(); |
225 subscription.cancel(); | 225 subscription.cancel(); |
226 } else { | 226 } else { |
227 sink.add(data); | 227 sink.add(data); |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 message['replyTo'] = responsePort.sendPort; | 617 message['replyTo'] = responsePort.sendPort; |
618 return new Future.sync(() { | 618 return new Future.sync(() { |
619 port.send(message); | 619 port.send(message); |
620 return responsePort.first.then((response) { | 620 return responsePort.first.then((response) { |
621 if (response.containsKey('success')) return response['success']; | 621 if (response.containsKey('success')) return response['success']; |
622 return new Future.error( | 622 return new Future.error( |
623 new dart.CrossIsolateException.deserialize(response['error'])); | 623 new dart.CrossIsolateException.deserialize(response['error'])); |
624 }); | 624 }); |
625 }); | 625 }); |
626 } | 626 } |
OLD | NEW |