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

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: Remove debug-print. Created 4 years, 5 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 | sdk/lib/async/stream_controller.dart » ('j') | sdk/lib/async/stream_controller.dart » ('J')
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..77fe7e9b2238ed09b2df973529c76984f894450a 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 new Future.value(null);
Lasse Reichstein Nielsen 2016/08/01 15:23:26 We have `Future._nullFuture` as a reusable null-va
floitsch 2016/08/01 21:00:37 Done.
});
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 | « no previous file | sdk/lib/async/stream_controller.dart » ('j') | sdk/lib/async/stream_controller.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698