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

Unified Diff: sdk/lib/async/stream.dart

Issue 15999002: Add Stream.drain() method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up impl and comments. Created 7 years, 7 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 | « no previous file | tests/lib/async/stream_controller_async_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/stream.dart
diff --git a/sdk/lib/async/stream.dart b/sdk/lib/async/stream.dart
index 4be59b7326b09d1f0706db8ddf935b85f13c1097..dbe3374e8f088733bd0c49563012fc577611a200 100644
--- a/sdk/lib/async/stream.dart
+++ b/sdk/lib/async/stream.dart
@@ -499,6 +499,20 @@ abstract class Stream<T> {
}
/**
+ * Discards all data on the stream, but signals when it's done or an error
+ * occured.
+ *
+ * When subscribing using [drain], cancelOnError will be true. This means
+ * that the future will complete with the first error on the stream and then
+ * cancel the subscription.
+ *
+ * In case of a `done` event the future completes with the given
+ * [futureValue].
+ */
+ Future drain([var futureValue]) => listen(null, cancelOnError: true)
+ .asFuture(futureValue);
+
+ /**
* Provides at most the first [n] values of this stream.
*
* Forwards the first [n] data events of this stream, and all error
« no previous file with comments | « no previous file | tests/lib/async/stream_controller_async_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698