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 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 * it may consume all the errors and only stop at a done event, | 1486 * it may consume all the errors and only stop at a done event, |
1487 * or it may be canceled early if the receiver don't want any further events. | 1487 * or it may be canceled early if the receiver don't want any further events. |
1488 * | 1488 * |
1489 * If the consumer stops listening because of some error preventing it | 1489 * If the consumer stops listening because of some error preventing it |
1490 * from continuing, it may report this error in the returned future, | 1490 * from continuing, it may report this error in the returned future, |
1491 * otherwise it will just complete the future with `null`. | 1491 * otherwise it will just complete the future with `null`. |
1492 */ | 1492 */ |
1493 Future addStream(Stream<S> stream); | 1493 Future addStream(Stream<S> stream); |
1494 | 1494 |
1495 /** | 1495 /** |
1496 * Tells the consumer that no futher streams will be added. | 1496 * Tells the consumer that no further streams will be added. |
1497 * | 1497 * |
1498 * This allows the consumer to complete any remaining work and release | 1498 * This allows the consumer to complete any remaining work and release |
1499 * resources that are no longer needed | 1499 * resources that are no longer needed |
1500 * | 1500 * |
1501 * Returns a future which is completed when the consumer has shut down. | 1501 * Returns a future which is completed when the consumer has shut down. |
1502 * If cleaning up can fail, the error may be reported in the returned future, | 1502 * If cleaning up can fail, the error may be reported in the returned future, |
1503 * otherwise it completes with `null`. | 1503 * otherwise it completes with `null`. |
1504 */ | 1504 */ |
1505 Future close(); | 1505 Future close(); |
1506 } | 1506 } |
(...skipping 13 matching lines...) Expand all Loading... |
1520 * be delayed until the underlying system has consumed the data added by the | 1520 * be delayed until the underlying system has consumed the data added by the |
1521 * [EventSink] methods. | 1521 * [EventSink] methods. |
1522 * | 1522 * |
1523 * When [EventSink] methods are used, the [done] [Future] can be used to | 1523 * When [EventSink] methods are used, the [done] [Future] can be used to |
1524 * catch any errors. | 1524 * catch any errors. |
1525 * | 1525 * |
1526 * When [close] is called, it will return the [done] [Future]. | 1526 * When [close] is called, it will return the [done] [Future]. |
1527 */ | 1527 */ |
1528 abstract class StreamSink<S> implements EventSink<S>, StreamConsumer<S> { | 1528 abstract class StreamSink<S> implements EventSink<S>, StreamConsumer<S> { |
1529 /** | 1529 /** |
1530 * Tells the stream sink that no futher streams will be added. | 1530 * Tells the stream sink that no further streams will be added. |
1531 * | 1531 * |
1532 * This allows the stream sink to complete any remaining work and release | 1532 * This allows the stream sink to complete any remaining work and release |
1533 * resources that are no longer needed | 1533 * resources that are no longer needed |
1534 * | 1534 * |
1535 * Returns a future which is completed when the stream sink has shut down. | 1535 * Returns a future which is completed when the stream sink has shut down. |
1536 * If cleaning up can fail, the error may be reported in the returned future, | 1536 * If cleaning up can fail, the error may be reported in the returned future, |
1537 * otherwise it completes with `null`. | 1537 * otherwise it completes with `null`. |
1538 * | 1538 * |
1539 * Returns the same future as [done]. | 1539 * Returns the same future as [done]. |
1540 * | 1540 * |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 class _ControllerEventSinkWrapper<T> implements EventSink<T> { | 1743 class _ControllerEventSinkWrapper<T> implements EventSink<T> { |
1744 EventSink _sink; | 1744 EventSink _sink; |
1745 _ControllerEventSinkWrapper(this._sink); | 1745 _ControllerEventSinkWrapper(this._sink); |
1746 | 1746 |
1747 void add(T data) { _sink.add(data); } | 1747 void add(T data) { _sink.add(data); } |
1748 void addError(error, [StackTrace stackTrace]) { | 1748 void addError(error, [StackTrace stackTrace]) { |
1749 _sink.addError(error, stackTrace); | 1749 _sink.addError(error, stackTrace); |
1750 } | 1750 } |
1751 void close() { _sink.close(); } | 1751 void close() { _sink.close(); } |
1752 } | 1752 } |
OLD | NEW |