| 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 12 matching lines...) Expand all Loading... |
| 23 }); | 23 }); |
| 24 return controller.stream; | 24 return controller.stream; |
| 25 } | 25 } |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * Stream that outputs events from the [sources] in cyclic order. | 28 * Stream that outputs events from the [sources] in cyclic order. |
| 29 * | 29 * |
| 30 * The merged streams are paused and resumed in order to ensure the proper | 30 * The merged streams are paused and resumed in order to ensure the proper |
| 31 * order of output events. | 31 * order of output events. |
| 32 */ | 32 */ |
| 33 factory Stream.cyclic(Iterable<Stream> sources) = CyclicScheduleStream<T>; | 33 factory Stream.cyclic(Iterable<Stream> sources) { |
| 34 return new CyclicScheduleStream<T>(sources); |
| 35 } |
| 34 | 36 |
| 35 /** | 37 /** |
| 36 * Create a stream that forwards data from the highest priority active source. | 38 * Create a stream that forwards data from the highest priority active source. |
| 37 * | 39 * |
| 38 * Sources are provided in order of increasing priority, and only data from | 40 * Sources are provided in order of increasing priority, and only data from |
| 39 * the highest priority source stream that has provided data are output | 41 * the highest priority source stream that has provided data are output |
| 40 * on the created stream. | 42 * on the created stream. |
| 41 * | 43 * |
| 42 * Errors from the most recent active stream, and any higher priority stream, | 44 * Errors from the most recent active stream, and any higher priority stream, |
| 43 * are forwarded to the created stream. | 45 * are forwarded to the created stream. |
| 44 * | 46 * |
| 45 * If a higher priority source stream completes without providing data, | 47 * If a higher priority source stream completes without providing data, |
| 46 * it will have no effect on lower priority streams. | 48 * it will have no effect on lower priority streams. |
| 47 */ | 49 */ |
| 48 factory Stream.superceding(Iterable<Stream<T>> sources) = SupercedeStream<T>; | 50 factory Stream.superceding(Iterable<Stream<T>> sources) { |
| 51 return new SupercedeStream<T>(sources); |
| 52 } |
| 49 | 53 |
| 50 /** | 54 /** |
| 51 * Add a subscription to this stream. | 55 * Add a subscription to this stream. |
| 52 * | 56 * |
| 53 * On each data event from this stream, the subscribers [onData] handler | 57 * On each data event from this stream, the subscribers [onData] handler |
| 54 * is called. If [onData] is null, nothing happens. | 58 * is called. If [onData] is null, nothing happens. |
| 55 * | 59 * |
| 56 * On errors from this stream, the [onError] handler is given a | 60 * On errors from this stream, the [onError] handler is given a |
| 57 * [AsyncError] object describing the error. | 61 * [AsyncError] object describing the error. |
| 58 * | 62 * |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 sink.signalError(error); | 833 sink.signalError(error); |
| 830 } | 834 } |
| 831 | 835 |
| 832 /** | 836 /** |
| 833 * Handle an incoming done event. | 837 * Handle an incoming done event. |
| 834 */ | 838 */ |
| 835 void handleDone(StreamSink<T> sink) { | 839 void handleDone(StreamSink<T> sink) { |
| 836 sink.close(); | 840 sink.close(); |
| 837 } | 841 } |
| 838 } | 842 } |
| OLD | NEW |