| OLD | NEW |
| 1 library catch_errors; | 1 library catch_errors; |
| 2 | 2 |
| 3 import 'dart:async'; | 3 import 'dart:async'; |
| 4 | 4 |
| 5 Stream catchErrors(void body()) { | 5 Stream catchErrors(void body()) { |
| 6 StreamController controller; | 6 StreamController controller; |
| 7 | 7 |
| 8 bool onError(e) { | 8 bool onError(e) { |
| 9 controller.add(e); | 9 controller.add(e); |
| 10 return true; | 10 return true; |
| 11 } | 11 } |
| 12 | 12 |
| 13 void onDone() { | |
| 14 controller.close(); | |
| 15 } | |
| 16 | |
| 17 void onListen() { | 13 void onListen() { |
| 18 runZonedExperimental(body, onError: onError, onDone: onDone); | 14 runZoned(body, onError: onError); |
| 19 } | 15 } |
| 20 | 16 |
| 21 controller = new StreamController(onListen: onListen); | 17 controller = new StreamController(onListen: onListen); |
| 22 return controller.stream; | 18 return controller.stream; |
| 23 } | 19 } |
| 24 | |
| 25 Future waitForCompletion(void body()) { | |
| 26 Completer completer = new Completer.sync(); | |
| 27 runZonedExperimental(body, onDone: completer.complete); | |
| 28 return completer.future; | |
| 29 } | |
| OLD | NEW |