Chromium Code Reviews| 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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 825 * | 825 * |
| 826 * If the subscription is paused more than once, an equal number | 826 * If the subscription is paused more than once, an equal number |
| 827 * of resumes must be performed to resume the stream. | 827 * of resumes must be performed to resume the stream. |
| 828 */ | 828 */ |
| 829 void pause([Future resumeSignal]); | 829 void pause([Future resumeSignal]); |
| 830 | 830 |
| 831 /** | 831 /** |
| 832 * Resume after a pause. | 832 * Resume after a pause. |
| 833 */ | 833 */ |
| 834 void resume(); | 834 void resume(); |
| 835 | |
| 836 /** | |
| 837 * Returns a future that handles the [onDone] and [onError] callbacks. | |
| 838 * | |
| 839 * This method *overwrites* the existing [onDone] and [onError] callbacks | |
| 840 * with new ones that complete the returned future. | |
| 841 * | |
| 842 * In case of an error the subscription will automatically cancel (even | |
| 843 * when it was listening with `unsubscribeOnError` set to `false`). | |
|
Lasse Reichstein Nielsen
2013/04/15 10:19:15
"This also makes the subscription cancel on any er
floitsch
2013/04/15 12:16:37
If you change the onError handler it won't receive
| |
| 844 * | |
| 845 * In case of a `done` event the future completes with the given | |
| 846 * [futureValue]. | |
| 847 */ | |
| 848 Future asFuture([var futureValue]); | |
| 835 } | 849 } |
| 836 | 850 |
| 837 | 851 |
| 838 /** | 852 /** |
| 839 * An interface that abstracts creation or handling of [Stream] events. | 853 * An interface that abstracts creation or handling of [Stream] events. |
| 840 */ | 854 */ |
| 841 abstract class EventSink<T> { | 855 abstract class EventSink<T> { |
| 842 /** Create a data event */ | 856 /** Create a data event */ |
| 843 void add(T event); | 857 void add(T event); |
| 844 /** Create an async error. */ | 858 /** Create an async error. */ |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1150 } | 1164 } |
| 1151 | 1165 |
| 1152 class _EventOutputSinkWrapper<T> extends EventSink<T> { | 1166 class _EventOutputSinkWrapper<T> extends EventSink<T> { |
| 1153 _EventOutputSink _sink; | 1167 _EventOutputSink _sink; |
| 1154 _EventOutputSinkWrapper(this._sink); | 1168 _EventOutputSinkWrapper(this._sink); |
| 1155 | 1169 |
| 1156 void add(T data) { _sink._sendData(data); } | 1170 void add(T data) { _sink._sendData(data); } |
| 1157 void addError(AsyncError error) { _sink._sendError(error); } | 1171 void addError(AsyncError error) { _sink._sendError(error); } |
| 1158 void close() { _sink._sendDone(); } | 1172 void close() { _sink._sendDone(); } |
| 1159 } | 1173 } |
| OLD | NEW |