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

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

Issue 1189873004: Update documentation of Stream.pipe to match behavior. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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 | no next file » | 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 successfully added
484 * to it.
485 * If the stream produces an error, the piping will stop after that error,
486 * and the stream consumer will not be closed.
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 * or after an error has made the piping stop.
Søren Gjesse 2015/06/17 10:56:04 In the error case the future completes with an err
Lasse Reichstein Nielsen 2015/06/18 08:47:06 Nope. Would be nice, but that's not what is happen
491 *
492 * The [streamConsumer] should not be used for adding other events until
493 * the returned future completes.
Søren Gjesse 2015/06/17 10:56:04 In the "success" case where the streamConsumer is
Lasse Reichstein Nielsen 2015/06/18 08:47:05 True. I'm not sure the behavior is actually what w
487 */ 494 */
488 Future pipe(StreamConsumer<T> streamConsumer) { 495 Future pipe(StreamConsumer<T> streamConsumer) {
489 return streamConsumer.addStream(this).then((_) => streamConsumer.close()); 496 return streamConsumer.addStream(this).then((_) => streamConsumer.close());
490 } 497 }
491 498
492 /** 499 /**
493 * Chains this stream as the input of the provided [StreamTransformer]. 500 * Chains this stream as the input of the provided [StreamTransformer].
494 * 501 *
495 * Returns the result of [:streamTransformer.bind:] itself. 502 * Returns the result of [:streamTransformer.bind:] itself.
496 * 503 *
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 class _ControllerEventSinkWrapper<T> implements EventSink<T> { 1720 class _ControllerEventSinkWrapper<T> implements EventSink<T> {
1714 EventSink _sink; 1721 EventSink _sink;
1715 _ControllerEventSinkWrapper(this._sink); 1722 _ControllerEventSinkWrapper(this._sink);
1716 1723
1717 void add(T data) { _sink.add(data); } 1724 void add(T data) { _sink.add(data); }
1718 void addError(error, [StackTrace stackTrace]) { 1725 void addError(error, [StackTrace stackTrace]) {
1719 _sink.addError(error, stackTrace); 1726 _sink.addError(error, stackTrace);
1720 } 1727 }
1721 void close() { _sink.close(); } 1728 void close() { _sink.close(); }
1722 } 1729 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698