| 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 import 'package:async_helper/async_helper.dart'; | 5 import 'package:async_helper/async_helper.dart'; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'catch_errors.dart'; | 8 import 'catch_errors.dart'; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 catchErrors(() { | 21 catchErrors(() { |
| 22 catchErrors(() { | 22 catchErrors(() { |
| 23 controller = new StreamController(); | 23 controller = new StreamController(); |
| 24 stream = controller.stream | 24 stream = controller.stream |
| 25 .map((x) { | 25 .map((x) { |
| 26 events.add("map $x"); | 26 events.add("map $x"); |
| 27 return x + 100; | 27 return x + 100; |
| 28 }) | 28 }) |
| 29 .asBroadcastStream(); | 29 .asBroadcastStream(); |
| 30 stream | 30 stream |
| 31 .transform(new StreamTransformer( | 31 .transform(new StreamTransformer.fromHandlers( |
| 32 handleError: (e, sink) => sink.add("error $e"))) | 32 handleError: (e, st, sink) { sink.add("error $e"); })) |
| 33 .listen((x) { events.add("stream $x"); }); | 33 .listen((x) { events.add("stream $x"); }); |
| 34 runAsync(() { | 34 runAsync(() { |
| 35 controller.add(1); | 35 controller.add(1); |
| 36 // Errors are not allowed to traverse boundaries, but in this case the | 36 // Errors are not allowed to traverse boundaries, but in this case the |
| 37 // first listener of the broadcast stream is in the same error-zone. So | 37 // first listener of the broadcast stream is in the same error-zone. So |
| 38 // this should work. | 38 // this should work. |
| 39 controller.addError(2); | 39 controller.addError(2); |
| 40 controller.close(); | 40 controller.close(); |
| 41 }); | 41 }); |
| 42 }).listen((x) { | 42 }).listen((x) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 55 "stream 101", | 55 "stream 101", |
| 56 "stream2 101", | 56 "stream2 101", |
| 57 "stream error 2", | 57 "stream error 2", |
| 58 2, // Caught by the inner `catchErrors`. | 58 2, // Caught by the inner `catchErrors`. |
| 59 ], | 59 ], |
| 60 events); | 60 events); |
| 61 asyncEnd(); | 61 asyncEnd(); |
| 62 }); | 62 }); |
| 63 }); | 63 }); |
| 64 } | 64 } |
| OLD | NEW |