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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 * | 471 * |
472 * The returned stream is a broadcast stream if this stream is. | 472 * The returned stream is a broadcast stream if this stream is. |
473 * If a broadcast stream is listened to more than once, each subscription | 473 * If a broadcast stream is listened to more than once, each subscription |
474 * will individually call `convert` and expand the events. | 474 * will individually call `convert` and expand the events. |
475 */ | 475 */ |
476 Stream expand(Iterable convert(T value)) { | 476 Stream expand(Iterable convert(T value)) { |
477 return new _ExpandStream<T, dynamic>(this, convert); | 477 return new _ExpandStream<T, dynamic>(this, convert); |
478 } | 478 } |
479 | 479 |
480 /** | 480 /** |
481 * Binds this stream as the input of the provided [StreamConsumer]. | 481 * Pipe the events of this stream into [streamConsumer]. |
482 * | 482 * |
483 * The `streamConsumer` is closed when the stream has been added to it. | 483 * The `streamConsumer` is closed when this stream has been added |
484 * to it. | |
485 * | |
486 * If the stream produces an error, the piping will stop after that error. | |
484 * | 487 * |
485 * Returns a future which completes when the stream has been consumed | 488 * Returns a future which completes when the stream has been consumed |
486 * and the consumer has been closed. | 489 * and the consumer has been closed. |
490 * | |
491 * The returned future completes with the same result as the future returned | |
492 * by [StreamConsumer.close]. | |
493 * If the adding of the stream itself fails in some way, | |
494 * then the consumer is expected to be closed, and won't be closed again. | |
Søren Gjesse
2015/06/18 08:00:14
Why 'is expected'? Sounds a bit vague.
Lasse Reichstein Nielsen
2015/06/18 08:47:06
Because the StreamConsumer.addStream documentation
| |
495 * In that case the returned future completes with the error from adding | |
496 * the stream. | |
487 */ | 497 */ |
488 Future pipe(StreamConsumer<T> streamConsumer) { | 498 Future pipe(StreamConsumer<T> streamConsumer) { |
489 return streamConsumer.addStream(this).then((_) => streamConsumer.close()); | 499 return streamConsumer.addStream(this).then((_) => streamConsumer.close()); |
490 } | 500 } |
491 | 501 |
492 /** | 502 /** |
493 * Chains this stream as the input of the provided [StreamTransformer]. | 503 * Chains this stream as the input of the provided [StreamTransformer]. |
494 * | 504 * |
495 * Returns the result of [:streamTransformer.bind:] itself. | 505 * Returns the result of [:streamTransformer.bind:] itself. |
496 * | 506 * |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1713 class _ControllerEventSinkWrapper<T> implements EventSink<T> { | 1723 class _ControllerEventSinkWrapper<T> implements EventSink<T> { |
1714 EventSink _sink; | 1724 EventSink _sink; |
1715 _ControllerEventSinkWrapper(this._sink); | 1725 _ControllerEventSinkWrapper(this._sink); |
1716 | 1726 |
1717 void add(T data) { _sink.add(data); } | 1727 void add(T data) { _sink.add(data); } |
1718 void addError(error, [StackTrace stackTrace]) { | 1728 void addError(error, [StackTrace stackTrace]) { |
1719 _sink.addError(error, stackTrace); | 1729 _sink.addError(error, stackTrace); |
1720 } | 1730 } |
1721 void close() { _sink.close(); } | 1731 void close() { _sink.close(); } |
1722 } | 1732 } |
OLD | NEW |