| 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 /** | 5 /** |
| 6 * Capture asynchronous results into synchronous values, and release them again. | 6 * Capture asynchronous results into synchronous values, and release them again. |
| 7 * | 7 * |
| 8 * Capturing a result (either a returned value or a thrown error) | 8 * Capturing a result (either a returned value or a thrown error) |
| 9 * means converting it into a [Result] - | 9 * means converting it into a [Result] - |
| 10 * either a [ValueResult] or an [ErrorResult]. | 10 * either a [ValueResult] or an [ErrorResult]. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 * Shorthand for transforming the stream using [CaptureStreamTransformer]. | 90 * Shorthand for transforming the stream using [CaptureStreamTransformer]. |
| 91 */ | 91 */ |
| 92 static Stream<Result> captureStream(Stream source) { | 92 static Stream<Result> captureStream(Stream source) { |
| 93 return source.transform(const CaptureStreamTransformer()); | 93 return source.transform(const CaptureStreamTransformer()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 /** | 96 /** |
| 97 * Release a stream of [result] values into a stream of the results. | 97 * Release a stream of [result] values into a stream of the results. |
| 98 * | 98 * |
| 99 * `Result` values of the source stream become value or error events in | 99 * `Result` values of the source stream become value or error events in |
| 100 * the retuned stream as appropriate. | 100 * the returned stream as appropriate. |
| 101 * Errors from the source stream become errors in the returned stream. | 101 * Errors from the source stream become errors in the returned stream. |
| 102 * | 102 * |
| 103 * Shorthand for transforming the stream using [ReleaseStreamTransformer]. | 103 * Shorthand for transforming the stream using [ReleaseStreamTransformer]. |
| 104 */ | 104 */ |
| 105 static Stream releaseStream(Stream<Result> source) { | 105 static Stream releaseStream(Stream<Result> source) { |
| 106 return source.transform(const ReleaseStreamTransformer()); | 106 return source.transform(const ReleaseStreamTransformer()); |
| 107 } | 107 } |
| 108 | 108 |
| 109 /** | 109 /** |
| 110 * Converts a result of a result to a single result. | 110 * Converts a result of a result to a single result. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 } | 282 } |
| 283 } | 283 } |
| 284 void addError(Object error, [StackTrace stackTrace]) { | 284 void addError(Object error, [StackTrace stackTrace]) { |
| 285 // Errors may be added by intermediate processing, even if it is never | 285 // Errors may be added by intermediate processing, even if it is never |
| 286 // added by CaptureSink. | 286 // added by CaptureSink. |
| 287 _sink.addError(error, stackTrace); | 287 _sink.addError(error, stackTrace); |
| 288 } | 288 } |
| 289 | 289 |
| 290 void close() { _sink.close(); } | 290 void close() { _sink.close(); } |
| 291 } | 291 } |
| OLD | NEW |