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 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 onError: future._completeError, | 883 onError: future._completeError, |
884 onDone: () { | 884 onDone: () { |
885 future._complete(result); | 885 future._complete(result); |
886 }, | 886 }, |
887 cancelOnError: true); | 887 cancelOnError: true); |
888 return future; | 888 return future; |
889 } | 889 } |
890 | 890 |
891 /** | 891 /** |
892 * Discards all data on the stream, but signals when it's done or an error | 892 * Discards all data on the stream, but signals when it's done or an error |
893 * occured. | 893 * occurred. |
894 * | 894 * |
895 * When subscribing using [drain], cancelOnError will be true. This means | 895 * When subscribing using [drain], cancelOnError will be true. This means |
896 * that the future will complete with the first error on the stream and then | 896 * that the future will complete with the first error on the stream and then |
897 * cancel the subscription. | 897 * cancel the subscription. |
898 * | 898 * |
899 * In case of a `done` event the future completes with the given | 899 * In case of a `done` event the future completes with the given |
900 * [futureValue]. | 900 * [futureValue]. |
901 */ | 901 */ |
902 Future<E> drain<E>([E futureValue]) | 902 Future<E> drain<E>([E futureValue]) |
903 => listen(null, cancelOnError: true).asFuture<E>(futureValue); | 903 => listen(null, cancelOnError: true).asFuture<E>(futureValue); |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 * This allows the stream sink to complete any remaining work and release | 1616 * This allows the stream sink to complete any remaining work and release |
1617 * resources that are no longer needed | 1617 * resources that are no longer needed |
1618 * | 1618 * |
1619 * Returns a future which is completed when the stream sink has shut down. | 1619 * Returns a future which is completed when the stream sink has shut down. |
1620 * If cleaning up can fail, the error may be reported in the returned future, | 1620 * If cleaning up can fail, the error may be reported in the returned future, |
1621 * otherwise it completes with `null`. | 1621 * otherwise it completes with `null`. |
1622 * | 1622 * |
1623 * Returns the same future as [done]. | 1623 * Returns the same future as [done]. |
1624 * | 1624 * |
1625 * The stream sink may close before the [close] method is called, either due | 1625 * The stream sink may close before the [close] method is called, either due |
1626 * to an error or because it is itself provding events to someone who has | 1626 * to an error or because it is itself providing events to someone who has |
1627 * stopped listening. In that case, the [done] future is completed first, | 1627 * stopped listening. In that case, the [done] future is completed first, |
1628 * and the `close` method will return the `done` future when called. | 1628 * and the `close` method will return the `done` future when called. |
1629 * | 1629 * |
1630 * Unifies [StreamConsumer.close] and [EventSink.close] which both mark their | 1630 * Unifies [StreamConsumer.close] and [EventSink.close] which both mark their |
1631 * object as not expecting any further events. | 1631 * object as not expecting any further events. |
1632 */ | 1632 */ |
1633 Future close(); | 1633 Future close(); |
1634 | 1634 |
1635 /** | 1635 /** |
1636 * Return a future which is completed when the [StreamSink] is finished. | 1636 * Return a future which is completed when the [StreamSink] is finished. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1827 class _ControllerEventSinkWrapper<T> implements EventSink<T> { | 1827 class _ControllerEventSinkWrapper<T> implements EventSink<T> { |
1828 EventSink _sink; | 1828 EventSink _sink; |
1829 _ControllerEventSinkWrapper(this._sink); | 1829 _ControllerEventSinkWrapper(this._sink); |
1830 | 1830 |
1831 void add(T data) { _sink.add(data); } | 1831 void add(T data) { _sink.add(data); } |
1832 void addError(error, [StackTrace stackTrace]) { | 1832 void addError(error, [StackTrace stackTrace]) { |
1833 _sink.addError(error, stackTrace); | 1833 _sink.addError(error, stackTrace); |
1834 } | 1834 } |
1835 void close() { _sink.close(); } | 1835 void close() { _sink.close(); } |
1836 } | 1836 } |
OLD | NEW |