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

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

Issue 2202533003: Return futures on Stream.cancel when possible. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Don't make Pipe.cancel wait for the null future. Created 4 years, 3 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 | « CHANGELOG.md ('k') | sdk/lib/async/stream_impl.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 7661d9ffe99978261371223a41a66b8f9833d8a8..f4abf9aac9c2cda45b9b6da83c06c4f434724620 100644
--- a/sdk/lib/async/stream.dart
+++ b/sdk/lib/async/stream.dart
@@ -232,6 +232,7 @@ abstract class Stream<T> {
onCancel: () {
if (timer != null) timer.cancel();
timer = null;
+ return Future._nullFuture;
});
return controller.stream;
}
@@ -441,7 +442,7 @@ abstract class Stream<T> {
onListen: onListen,
onPause: () { subscription.pause(); },
onResume: () { subscription.resume(); },
- onCancel: () { subscription.cancel(); },
+ onCancel: () => subscription.cancel(),
sync: true
);
}
@@ -499,7 +500,7 @@ abstract class Stream<T> {
onListen: onListen,
onPause: () { subscription.pause(); },
onResume: () { subscription.resume(); },
- onCancel: () { subscription.cancel(); },
+ onCancel: () => subscription.cancel(),
sync: true
);
}
@@ -1407,7 +1408,10 @@ abstract class StreamSubscription<T> {
* the subscription is canceled.
*
* Returns a future that is completed once the stream has finished
- * its cleanup. May also return `null` if no cleanup was necessary.
+ * its cleanup.
+ *
+ * For historical reasons, may also return `null` if no cleanup was necessary.
+ * Returning `null` is deprecated and should be avoided.
*
* Typically, futures are returned when the stream needs to release resources.
* For example, a stream might need to close an open file (as an asynchronous
@@ -1711,7 +1715,7 @@ abstract class StreamTransformer<S, T> {
* },
* onPause: () { subscription.pause(); },
* onResume: () { subscription.resume(); },
- * onCancel: () { subscription.cancel(); },
+ * onCancel: () => subscription.cancel(),
* sync: true);
* return controller.stream.listen(null);
* });
« no previous file with comments | « CHANGELOG.md ('k') | sdk/lib/async/stream_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698