| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 completer.completeError(e.error, e.stackTrace); | 146 completer.completeError(e.error, e.stackTrace); |
| 147 }, | 147 }, |
| 148 onDone: () { | 148 onDone: () { |
| 149 completer.complete(value); | 149 completer.complete(value); |
| 150 }, | 150 }, |
| 151 unsubscribeOnError: true); | 151 unsubscribeOnError: true); |
| 152 return completer.future; | 152 return completer.future; |
| 153 } | 153 } |
| 154 | 154 |
| 155 // Deprecated method, previously called 'pipe', retained for compatibility. | 155 // Deprecated method, previously called 'pipe', retained for compatibility. |
| 156 Signal pipeInto(Sink<T> sink, | 156 Future pipeInto(Sink<T> sink, |
| 157 {void onError(AsyncError error), | 157 {void onError(AsyncError error), |
| 158 bool unsubscribeOnError}) { | 158 bool unsubscribeOnError}) { |
| 159 SignalCompleter completer = new SignalCompleter(); | 159 Completer completer = new Completer(); |
| 160 this.listen( | 160 this.listen( |
| 161 sink.add, | 161 sink.add, |
| 162 onError: onError, | 162 onError: onError, |
| 163 onDone: () { | 163 onDone: () { |
| 164 sink.close(); | 164 sink.close(); |
| 165 completer.complete(); | 165 completer.complete(null); |
| 166 }, | 166 }, |
| 167 unsubscribeOnError: unsubscribeOnError); | 167 unsubscribeOnError: unsubscribeOnError); |
| 168 return completer.signal; | 168 return completer.future; |
| 169 } | 169 } |
| 170 | 170 |
| 171 | 171 |
| 172 /** | 172 /** |
| 173 * Check whether [match] occurs in the elements provided by this stream. | 173 * Check whether [match] occurs in the elements provided by this stream. |
| 174 * | 174 * |
| 175 * Completes the [Future] when the answer is known. | 175 * Completes the [Future] when the answer is known. |
| 176 * If this stream reports an error, the [Future] will report that error. | 176 * If this stream reports an error, the [Future] will report that error. |
| 177 */ | 177 */ |
| 178 Future<bool> contains(T match) { | 178 Future<bool> contains(T match) { |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 /** Set or override the error event handler of this subscription. */ | 709 /** Set or override the error event handler of this subscription. */ |
| 710 void onError(void handleError(AsyncError error)); | 710 void onError(void handleError(AsyncError error)); |
| 711 | 711 |
| 712 /** Set or override the done event handler of this subscription. */ | 712 /** Set or override the done event handler of this subscription. */ |
| 713 void onDone(void handleDone()); | 713 void onDone(void handleDone()); |
| 714 | 714 |
| 715 /** | 715 /** |
| 716 * Request that the stream pauses events until further notice. | 716 * Request that the stream pauses events until further notice. |
| 717 * | 717 * |
| 718 * If [resumeSignal] is provided, the stream will undo the pause | 718 * If [resumeSignal] is provided, the stream will undo the pause |
| 719 * when the signal completes. | 719 * when the future completes in any way. |
| 720 * A call to [resume] will also undo a pause. | 720 * A call to [resume] will also undo a pause. |
| 721 * | 721 * |
| 722 * If the subscription is paused more than once, an equal number | 722 * If the subscription is paused more than once, an equal number |
| 723 * of resumes must be performed to resume the stream. | 723 * of resumes must be performed to resume the stream. |
| 724 */ | 724 */ |
| 725 void pause([Signal resumeSignal]); | 725 void pause([Future resumeSignal]); |
| 726 | 726 |
| 727 /** | 727 /** |
| 728 * Resume after a pause. | 728 * Resume after a pause. |
| 729 */ | 729 */ |
| 730 void resume(); | 730 void resume(); |
| 731 } | 731 } |
| 732 | 732 |
| 733 | 733 |
| 734 /** | 734 /** |
| 735 * An interface that abstracts sending events into a [Stream]. | 735 * An interface that abstracts sending events into a [Stream]. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 sink.signalError(error); | 833 sink.signalError(error); |
| 834 } | 834 } |
| 835 | 835 |
| 836 /** | 836 /** |
| 837 * Handle an incoming done event. | 837 * Handle an incoming done event. |
| 838 */ | 838 */ |
| 839 void handleDone(StreamSink<T> sink) { | 839 void handleDone(StreamSink<T> sink) { |
| 840 sink.close(); | 840 sink.close(); |
| 841 } | 841 } |
| 842 } | 842 } |
| OLD | NEW |