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

Unified Diff: pkg/scheduled_test/lib/src/utils.dart

Issue 12678011: Miscellaneous small improvements for scheduled_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Guard against issue 9151 more thoroughly. Created 7 years, 9 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 | « pkg/scheduled_test/lib/src/schedule_error.dart ('k') | pkg/scheduled_test/test/scheduled_server_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/scheduled_test/lib/src/utils.dart
diff --git a/pkg/scheduled_test/lib/src/utils.dart b/pkg/scheduled_test/lib/src/utils.dart
index 12dc80bbfbfb08ce014f2a5b3750e55e667e73ca..57c341d888d021bf454f006991a6ac50af5ac646 100644
--- a/pkg/scheduled_test/lib/src/utils.dart
+++ b/pkg/scheduled_test/lib/src/utils.dart
@@ -92,24 +92,22 @@ Stream futureStream(Future<Stream> future) {
/// Returns a [Future] that will complete to the first element of [stream].
/// Unlike [Stream.first], this is safe to use with single-subscription streams.
Future streamFirst(Stream stream) {
- // TODO(nweiz): remove this when issue 8512 is fixed.
- var cancelled = false;
+ var stackTrace;
+ try {
+ throw '';
+ } catch (_, thrownStackTrace) {
+ stackTrace = thrownStackTrace;
+ }
+
var completer = new Completer();
var subscription;
subscription = stream.listen((value) {
- if (!cancelled) {
- cancelled = true;
- subscription.cancel();
- completer.complete(value);
- }
+ subscription.cancel();
+ completer.complete(value);
}, onError: (e) {
- if (!cancelled) {
- completer.completeError(e.error, e.stackTrace);
- }
+ completer.completeError(e.error, e.stackTrace);
}, onDone: () {
- if (!cancelled) {
- completer.completeError(new StateError("No elements"));
- }
+ completer.completeError(new StateError("No elements"), stackTrace);
}, unsubscribeOnError: true);
return completer.future;
}
« no previous file with comments | « pkg/scheduled_test/lib/src/schedule_error.dart ('k') | pkg/scheduled_test/test/scheduled_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698