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

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

Issue 1177343004: Add Stream.empty. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add test, fix impl. Created 5 years, 6 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 | sdk/lib/async/stream.dart » ('j') | sdk/lib/async/stream.dart » ('J')
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 /** 7 /**
8 * An object representing a delayed computation. 8 * An object representing a delayed computation.
9 * 9 *
10 * A [Future] is used to represent a potential value, or error, 10 * A [Future] is used to represent a potential value, or error,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 /** 175 /**
176 * A future whose value is available in the next event-loop iteration. 176 * A future whose value is available in the next event-loop iteration.
177 * 177 *
178 * If [value] is not a [Future], using this constructor is equivalent 178 * If [value] is not a [Future], using this constructor is equivalent
179 * to [:new Future<T>.sync(() => value):]. 179 * to [:new Future<T>.sync(() => value):].
180 * 180 *
181 * Use [Completer] to create a Future and complete it later. 181 * Use [Completer] to create a Future and complete it later.
182 */ 182 */
183 factory Future.value([value]) { 183 factory Future.value([value]) {
184 if (value == null) return _nullFuture;
sra1 2015/06/15 16:17:40 What is the purpose of this change? I think this
Lasse Reichstein Nielsen 2015/06/15 16:24:42 Ack, true. The purpose is entirely to save some sp
Lasse Reichstein Nielsen 2015/06/16 09:25:12 Rolling this change back.
184 return new _Future<T>.immediate(value); 185 return new _Future<T>.immediate(value);
185 } 186 }
186 187
187 /** 188 /**
188 * A future that completes with an error in the next event-loop iteration. 189 * A future that completes with an error in the next event-loop iteration.
189 * 190 *
190 * If [error] is `null`, it is replaced by a [NullThrownError]. 191 * If [error] is `null`, it is replaced by a [NullThrownError].
191 * 192 *
192 * Use [Completer] to create a future and complete it later. 193 * Use [Completer] to create a future and complete it later.
193 */ 194 */
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 if (replacement != null) { 721 if (replacement != null) {
721 error = _nonNullError(replacement.error); 722 error = _nonNullError(replacement.error);
722 stackTrace = replacement.stackTrace; 723 stackTrace = replacement.stackTrace;
723 } 724 }
724 result._completeError(error, stackTrace); 725 result._completeError(error, stackTrace);
725 } 726 }
726 727
727 /** Helper function that converts `null` to a [NullThrownError]. */ 728 /** Helper function that converts `null` to a [NullThrownError]. */
728 Object _nonNullError(Object error) => 729 Object _nonNullError(Object error) =>
729 (error != null) ? error : new NullThrownError(); 730 (error != null) ? error : new NullThrownError();
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/async/stream.dart » ('j') | sdk/lib/async/stream.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698