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

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

Issue 13680002: StreamConsumer has an addStream and a close functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comments. Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | sdk/lib/io/file_impl.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Core Stream types 8 // Core Stream types
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 10
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 * in order. 230 * in order.
231 */ 231 */
232 Stream expand(Iterable convert(T value)) { 232 Stream expand(Iterable convert(T value)) {
233 return new _ExpandStream<T, dynamic>(this, convert); 233 return new _ExpandStream<T, dynamic>(this, convert);
234 } 234 }
235 235
236 /** 236 /**
237 * Binds this stream as the input of the provided [StreamConsumer]. 237 * Binds this stream as the input of the provided [StreamConsumer].
238 */ 238 */
239 Future pipe(StreamConsumer<T, dynamic> streamConsumer) { 239 Future pipe(StreamConsumer<T, dynamic> streamConsumer) {
240 // TODO(floitsch): switch to:
241 // streamConsumer.addStream(this).then((_) => streamConsumer.close());
240 return streamConsumer.consume(this); 242 return streamConsumer.consume(this);
241 } 243 }
242 244
243 /** 245 /**
244 * Chains this stream as the input of the provided [StreamTransformer]. 246 * Chains this stream as the input of the provided [StreamTransformer].
245 * 247 *
246 * Returns the result of [:streamTransformer.bind:] itself. 248 * Returns the result of [:streamTransformer.bind:] itself.
247 */ 249 */
248 Stream transform(StreamTransformer<T, dynamic> streamTransformer) { 250 Stream transform(StreamTransformer<T, dynamic> streamTransformer) {
249 return streamTransformer.bind(this); 251 return streamTransformer.bind(this);
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 978
977 979
978 /** 980 /**
979 * The target of a [Stream.pipe] call. 981 * The target of a [Stream.pipe] call.
980 * 982 *
981 * The [Stream.pipe] call will pass itself to this object, and then return 983 * The [Stream.pipe] call will pass itself to this object, and then return
982 * the resulting [Future]. The pipe should complete the future when it's 984 * the resulting [Future]. The pipe should complete the future when it's
983 * done. 985 * done.
984 */ 986 */
985 abstract class StreamConsumer<S, T> { 987 abstract class StreamConsumer<S, T> {
988 // TODO(floitsch): generic types.
989 // Currently not possible to add generic types, since they clash with other
990 // types that have already been used.
991 Future addStream(Stream<S> stream);
992 Future close();
993
994
995 /**
996 * Consume is deprecated. Use [addStream] followed by [close] instead.
997 */
986 Future<T> consume(Stream<S> stream); 998 Future<T> consume(Stream<S> stream);
987 } 999 }
988 1000
989 1001
990 /** 1002 /**
991 * The target of a [Stream.transform] call. 1003 * The target of a [Stream.transform] call.
992 * 1004 *
993 * The [Stream.transform] call will pass itself to this object and then return 1005 * The [Stream.transform] call will pass itself to this object and then return
994 * the resulting stream. 1006 * the resulting stream.
995 */ 1007 */
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 1214
1203 /* TODO(8997): Implement EventSink instead, */ 1215 /* TODO(8997): Implement EventSink instead, */
1204 class _EventOutputSinkWrapper<T> extends StreamSink<T> { 1216 class _EventOutputSinkWrapper<T> extends StreamSink<T> {
1205 _EventOutputSink _sink; 1217 _EventOutputSink _sink;
1206 _EventOutputSinkWrapper(this._sink); 1218 _EventOutputSinkWrapper(this._sink);
1207 1219
1208 void add(T data) { _sink._sendData(data); } 1220 void add(T data) { _sink._sendData(data); }
1209 void addError(AsyncError error) { _sink._sendError(error); } 1221 void addError(AsyncError error) { _sink._sendError(error); }
1210 void close() { _sink._sendDone(); } 1222 void close() { _sink._sendDone(); }
1211 } 1223 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698