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

Unified Diff: sdk/lib/async/stream_controller.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
Index: sdk/lib/async/stream_controller.dart
diff --git a/sdk/lib/async/stream_controller.dart b/sdk/lib/async/stream_controller.dart
index 87b64e893d1e52dc89f7b55f5b3ca19175a0bba1..d6cc66784cd2ffd98eee403ea086900a9a4a750a 100644
--- a/sdk/lib/async/stream_controller.dart
+++ b/sdk/lib/async/stream_controller.dart
@@ -709,10 +709,9 @@ abstract class _StreamController<T> implements StreamController<T>,
if (onCancel != null) {
if (result == null) {
- // Only introduce a future if one is needed.
- // If _onCancel returns null, no future is needed.
+ // Introduce a future if none was returned.
try {
- result = onCancel();
+ result = onCancel() ?? new Future.value(null);
Lasse Reichstein Nielsen 2016/08/01 15:23:26 Use `Future._nullFuture`.
floitsch 2016/08/01 21:00:37 Moved the 'Future._nullFuture' to the `cancel` fun
} catch (e, s) {
// Return the error in the returned future.
// Complete it asynchronously, so there is time for a listener

Powered by Google App Engine
This is Rietveld 408576698