| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 result._setError(e); | 208 result._setError(e); |
| 209 }, | 209 }, |
| 210 onDone: () { | 210 onDone: () { |
| 211 result._setValue(value); | 211 result._setValue(value); |
| 212 }, | 212 }, |
| 213 unsubscribeOnError: true); | 213 unsubscribeOnError: true); |
| 214 return result; | 214 return result; |
| 215 } | 215 } |
| 216 | 216 |
| 217 // Deprecated method, previously called 'pipe', retained for compatibility. | 217 // Deprecated method, previously called 'pipe', retained for compatibility. |
| 218 Future pipeInto(Sink<T> sink, | 218 Future pipeInto(StreamSink<T> sink, |
| 219 {void onError(AsyncError error), | 219 {void onError(AsyncError error), |
| 220 bool unsubscribeOnError}) { | 220 bool unsubscribeOnError}) { |
| 221 _FutureImpl<T> result = new _FutureImpl<T>(); | 221 _FutureImpl<T> result = new _FutureImpl<T>(); |
| 222 this.listen( | 222 this.listen( |
| 223 sink.add, | 223 sink.add, |
| 224 onError: onError, | 224 onError: sink.signalError, |
| 225 onDone: () { | 225 onDone: () { |
| 226 sink.close(); | 226 sink.close(); |
| 227 result._setValue(null); | 227 result._setValue(null); |
| 228 }, | 228 }, |
| 229 unsubscribeOnError: unsubscribeOnError); | 229 unsubscribeOnError: unsubscribeOnError); |
| 230 return result; | 230 return result; |
| 231 } | 231 } |
| 232 | 232 |
| 233 | 233 |
| 234 /** | 234 /** |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 /** | 840 /** |
| 841 * Resume after a pause. | 841 * Resume after a pause. |
| 842 */ | 842 */ |
| 843 void resume(); | 843 void resume(); |
| 844 } | 844 } |
| 845 | 845 |
| 846 | 846 |
| 847 /** | 847 /** |
| 848 * An interface that abstracts sending events into a [Stream]. | 848 * An interface that abstracts sending events into a [Stream]. |
| 849 */ | 849 */ |
| 850 abstract class StreamSink<T> implements Sink<T> { | 850 abstract class StreamSink<T> { |
| 851 void add(T event); | 851 void add(T event); |
| 852 /** Signal an async error to the receivers of this sink's values. */ | 852 /** Signal an async error to the receivers of this sink's values. */ |
| 853 void signalError(AsyncError errorEvent); | 853 void signalError(AsyncError errorEvent); |
| 854 void close(); | 854 void close(); |
| 855 } | 855 } |
| 856 | 856 |
| 857 /** [Stream] wrapper that only exposes the [Stream] interface. */ | 857 /** [Stream] wrapper that only exposes the [Stream] interface. */ |
| 858 class StreamView<T> extends Stream<T> { | 858 class StreamView<T> extends Stream<T> { |
| 859 Stream<T> _stream; | 859 Stream<T> _stream; |
| 860 | 860 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 class _StreamOutputSinkWrapper<T> implements StreamSink<T> { | 1113 class _StreamOutputSinkWrapper<T> implements StreamSink<T> { |
| 1114 _StreamOutputSink _sink; | 1114 _StreamOutputSink _sink; |
| 1115 _StreamOutputSinkWrapper(this._sink); | 1115 _StreamOutputSinkWrapper(this._sink); |
| 1116 | 1116 |
| 1117 void add(T data) => _sink._sendData(data); | 1117 void add(T data) => _sink._sendData(data); |
| 1118 void signalError(AsyncError error) => _sink._sendError(error); | 1118 void signalError(AsyncError error) => _sink._sendError(error); |
| 1119 void close() => _sink._sendDone(); | 1119 void close() => _sink._sendDone(); |
| 1120 } | 1120 } |
| OLD | NEW |