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

Side by Side Diff: sdk/lib/async/stream_impl.dart

Issue 1295843002: The return-value of 'asFuture' isn't necessarily related to the Stream's type. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/lib/async/stream_subscription_as_future_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.async; 5 part of dart.async;
6 6
7 /** Abstract and private interface for a place to put events. */ 7 /** Abstract and private interface for a place to put events. */
8 abstract class _EventSink<T> { 8 abstract class _EventSink<T> {
9 void _add(T data); 9 void _add(T data);
10 void _addError(Object error, StackTrace stackTrace); 10 void _addError(Object error, StackTrace stackTrace);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // The user doesn't want to receive any further events. If there is an 196 // The user doesn't want to receive any further events. If there is an
197 // error or done event pending (waiting for the cancel to be done) discard 197 // error or done event pending (waiting for the cancel to be done) discard
198 // that event. 198 // that event.
199 _state &= ~_STATE_WAIT_FOR_CANCEL; 199 _state &= ~_STATE_WAIT_FOR_CANCEL;
200 if (_isCanceled) return _cancelFuture; 200 if (_isCanceled) return _cancelFuture;
201 _cancel(); 201 _cancel();
202 return _cancelFuture; 202 return _cancelFuture;
203 } 203 }
204 204
205 Future asFuture([var futureValue]) { 205 Future asFuture([var futureValue]) {
206 _Future<T> result = new _Future<T>(); 206 _Future result = new _Future();
207 207
208 // Overwrite the onDone and onError handlers. 208 // Overwrite the onDone and onError handlers.
209 _onDone = () { result._complete(futureValue); }; 209 _onDone = () { result._complete(futureValue); };
210 _onError = (error, stackTrace) { 210 _onError = (error, stackTrace) {
211 cancel(); 211 cancel();
212 result._completeError(error, stackTrace); 212 result._completeError(error, stackTrace);
213 }; 213 };
214 214
215 return result; 215 return result;
216 } 216 }
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 class _EmptyStream<T> extends Stream<T> { 1086 class _EmptyStream<T> extends Stream<T> {
1087 const _EmptyStream() : super._internal(); 1087 const _EmptyStream() : super._internal();
1088 bool get isBroadcast => true; 1088 bool get isBroadcast => true;
1089 StreamSubscription<T> listen(void onData(T data), 1089 StreamSubscription<T> listen(void onData(T data),
1090 {Function onError, 1090 {Function onError,
1091 void onDone(), 1091 void onDone(),
1092 bool cancelOnError}) { 1092 bool cancelOnError}) {
1093 return new _DoneStreamSubscription<T>(onDone); 1093 return new _DoneStreamSubscription<T>(onDone);
1094 } 1094 }
1095 } 1095 }
OLDNEW
« no previous file with comments | « no previous file | tests/lib/async/stream_subscription_as_future_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698