| OLD | NEW |
| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 * and each of these new events are then sent by the returned stream | 229 * and each of these new events are then sent by the returned stream |
| 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> streamConsumer) { |
| 240 // TODO(floitsch): switch to: | 240 // TODO(floitsch): switch to: |
| 241 // streamConsumer.addStream(this).then((_) => streamConsumer.close()); | 241 // streamConsumer.addStream(this).then((_) => streamConsumer.close()); |
| 242 return streamConsumer.consume(this); | 242 return streamConsumer.consume(this); |
| 243 } | 243 } |
| 244 | 244 |
| 245 /** | 245 /** |
| 246 * Chains this stream as the input of the provided [StreamTransformer]. | 246 * Chains this stream as the input of the provided [StreamTransformer]. |
| 247 * | 247 * |
| 248 * Returns the result of [:streamTransformer.bind:] itself. | 248 * Returns the result of [:streamTransformer.bind:] itself. |
| 249 */ | 249 */ |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 } | 881 } |
| 882 | 882 |
| 883 | 883 |
| 884 /** | 884 /** |
| 885 * The target of a [Stream.pipe] call. | 885 * The target of a [Stream.pipe] call. |
| 886 * | 886 * |
| 887 * The [Stream.pipe] call will pass itself to this object, and then return | 887 * The [Stream.pipe] call will pass itself to this object, and then return |
| 888 * the resulting [Future]. The pipe should complete the future when it's | 888 * the resulting [Future]. The pipe should complete the future when it's |
| 889 * done. | 889 * done. |
| 890 */ | 890 */ |
| 891 abstract class StreamConsumer<S, T> { | 891 abstract class StreamConsumer<S> { |
| 892 // TODO(floitsch): generic types. | |
| 893 // Currently not possible to add generic types, since they clash with other | |
| 894 // types that have already been used. | |
| 895 Future addStream(Stream<S> stream); | 892 Future addStream(Stream<S> stream); |
| 896 Future close(); | 893 Future close(); |
| 897 | 894 |
| 898 | 895 |
| 899 /** | 896 /** |
| 900 * Consume is deprecated. Use [addStream] followed by [close] instead. | 897 * Consume is deprecated. Use [addStream] followed by [close] instead. |
| 901 */ | 898 */ |
| 902 Future<T> consume(Stream<S> stream); | 899 Future consume(Stream<S> stream); |
| 903 } | 900 } |
| 904 | 901 |
| 905 | 902 |
| 906 /** | 903 /** |
| 907 * The target of a [Stream.transform] call. | 904 * The target of a [Stream.transform] call. |
| 908 * | 905 * |
| 909 * The [Stream.transform] call will pass itself to this object and then return | 906 * The [Stream.transform] call will pass itself to this object and then return |
| 910 * the resulting stream. | 907 * the resulting stream. |
| 911 */ | 908 */ |
| 912 abstract class StreamTransformer<S, T> { | 909 abstract class StreamTransformer<S, T> { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 } | 1127 } |
| 1131 | 1128 |
| 1132 class _EventOutputSinkWrapper<T> extends EventSink<T> { | 1129 class _EventOutputSinkWrapper<T> extends EventSink<T> { |
| 1133 _EventOutputSink _sink; | 1130 _EventOutputSink _sink; |
| 1134 _EventOutputSinkWrapper(this._sink); | 1131 _EventOutputSinkWrapper(this._sink); |
| 1135 | 1132 |
| 1136 void add(T data) { _sink._sendData(data); } | 1133 void add(T data) { _sink._sendData(data); } |
| 1137 void addError(AsyncError error) { _sink._sendError(error); } | 1134 void addError(AsyncError error) { _sink._sendError(error); } |
| 1138 void close() { _sink._sendDone(); } | 1135 void close() { _sink._sendDone(); } |
| 1139 } | 1136 } |
| OLD | NEW |