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

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

Issue 18915008: Let StreamSubscription.cancel return a Future. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove dir stuff. Created 7 years, 2 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_pipe.dart
diff --git a/sdk/lib/async/stream_pipe.dart b/sdk/lib/async/stream_pipe.dart
index b126747d848bcaa84ebe0315132ecc37ff042330..dde13f82670df2f0a764e7b334304869748dc27d 100644
--- a/sdk/lib/async/stream_pipe.dart
+++ b/sdk/lib/async/stream_pipe.dart
@@ -27,8 +27,23 @@ _runUserCode(userCode(), onSuccess(value), onError(error)) {
/** Helper function to make an onError argument to [_runUserCode]. */
_cancelAndError(StreamSubscription subscription, _Future future) =>
(error) {
floitsch 2013/10/12 18:53:57 You will need to update this for the stack-trace a
Lasse Reichstein Nielsen 2013/10/14 11:32:33 And not make it curried.
Anders Johnsen 2013/10/16 11:52:21 Done.
Anders Johnsen 2013/10/16 11:52:21 Done.
- subscription.cancel();
- future._completeError(error);
+ var cancelFuture = subscription.cancel();
+ if (cancelFuture != null) {
floitsch 2013/10/12 18:53:57 if (cancelFuture is Future) Users are used to wri
Anders Johnsen 2013/10/16 11:52:21 Done.
+ cancelFuture.whenComplete(() => future._completeError(error));
+ } else {
+ future._completeError(error);
+ }
+ };
+
+/** Helper function to make an onError argument to [_runUserCode]. */
+_cancelAndValue(StreamSubscription subscription, _Future future) =>
+ (value) {
+ var cancelFuture = subscription.cancel();
+ if (cancelFuture != null) {
floitsch 2013/10/12 18:53:57 ditto.
Anders Johnsen 2013/10/16 11:52:21 Done.
+ cancelFuture.whenComplete(() => future._complete(value));
+ } else {
+ future._complete(value);
+ }
};

Powered by Google App Engine
This is Rietveld 408576698