Chromium Code Reviews| Index: sdk/lib/async/stream_transformers.dart |
| diff --git a/sdk/lib/async/stream_transformers.dart b/sdk/lib/async/stream_transformers.dart |
| index e0982da4260ec621621a82b526aa21dac87f2be4..32fe28dfd820fab22c8b71e0099104cc59a28a89 100644 |
| --- a/sdk/lib/async/stream_transformers.dart |
| +++ b/sdk/lib/async/stream_transformers.dart |
| @@ -33,6 +33,9 @@ class _SinkTransformerStreamSubscription<S, T> |
| /// The subscription to the input stream. |
| StreamSubscription<S> _subscription; |
| + /// The cancelFuture (if any). |
| + Future _cancelFuture; |
|
Lasse Reichstein Nielsen
2016/08/01 15:23:26
Why a field? I only see it used inside one method?
floitsch
2016/08/01 21:00:37
Acknowledged.
|
| + |
| _SinkTransformerStreamSubscription(Stream<S> source, |
| _SinkMapper<S, T> mapper, |
| void onData(T data), |
| @@ -109,9 +112,9 @@ class _SinkTransformerStreamSubscription<S, T> |
| if (_isSubscribed) { |
| StreamSubscription subscription = _subscription; |
| _subscription = null; |
| - subscription.cancel(); |
| + _cancelFuture = subscription.cancel(); |
|
Lasse Reichstein Nielsen
2016/08/01 15:23:26
That is, why is _cancelFuture not a local variable
floitsch
2016/08/01 15:55:55
In case someone calls `cancel` multiple times.
Lasse Reichstein Nielsen
2016/08/01 16:49:38
Possibly a good point.
I'm not sure _onCancel will
floitsch
2016/08/01 21:00:37
You are right.
Changed a bit more...
|
| } |
| - return null; |
| + return _cancelFuture ?? new Future.value(null); |
| } |
| void _handleData(S data) { |