Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: sdk/lib/async/stream.dart

Issue 12088069: Remove Stream.cyclic/superceding. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/async/merge_stream.dart ('k') | tests/lib/async/merge_stream_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 * cancelled. 90 * cancelled.
91 * 91 *
92 * If this stream is already a broadcast stream, it is returned unmodified. 92 * If this stream is already a broadcast stream, it is returned unmodified.
93 */ 93 */
94 Stream<T> asBroadcastStream() { 94 Stream<T> asBroadcastStream() {
95 if (isBroadcast) return this; 95 if (isBroadcast) return this;
96 return new _SingleStreamMultiplexer<T>(this); 96 return new _SingleStreamMultiplexer<T>(this);
97 } 97 }
98 98
99 /** 99 /**
100 * Stream that outputs events from the [sources] in cyclic order.
101 *
102 * The merged streams are paused and resumed in order to ensure the proper
103 * order of output events.
104 */
105 factory Stream.cyclic(Iterable<Stream> sources) {
106 return new _CyclicScheduleStream<T>(sources);
107 }
108
109 /**
110 * Create a stream that forwards data from the highest priority active source.
111 *
112 * Sources are provided in order of increasing priority, and only data from
113 * the highest priority source stream that has provided data are output
114 * on the created stream.
115 *
116 * Errors from the most recent active stream, and any higher priority stream,
117 * are forwarded to the created stream.
118 *
119 * If a higher priority source stream completes without providing data,
120 * it will have no effect on lower priority streams.
121 */
122 factory Stream.superceding(Iterable<Stream<T>> sources) {
123 return new _SupercedeStream<T>(sources);
124 }
125
126 /**
127 * Add a subscription to this stream. 100 * Add a subscription to this stream.
128 * 101 *
129 * On each data event from this stream, the subscribers [onData] handler 102 * On each data event from this stream, the subscribers [onData] handler
130 * is called. If [onData] is null, nothing happens. 103 * is called. If [onData] is null, nothing happens.
131 * 104 *
132 * On errors from this stream, the [onError] handler is given a 105 * On errors from this stream, the [onError] handler is given a
133 * [AsyncError] object describing the error. 106 * [AsyncError] object describing the error.
134 * 107 *
135 * If this stream closes, the [onDone] handler is called. 108 * If this stream closes, the [onDone] handler is called.
136 * 109 *
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 * and each of these new events are then sent by the returned stream 162 * and each of these new events are then sent by the returned stream
190 * in order. 163 * in order.
191 */ 164 */
192 Stream expand(Iterable convert(T value)) { 165 Stream expand(Iterable convert(T value)) {
193 return new _ExpandStream<T, dynamic>(this, convert); 166 return new _ExpandStream<T, dynamic>(this, convert);
194 } 167 }
195 168
196 /** 169 /**
197 * Bind this stream as the input of the provided [StreamConsumer]. 170 * Bind this stream as the input of the provided [StreamConsumer].
198 */ 171 */
199 Future pipe(StreamConsumer<dynamic, T> streamConsumer) { 172 Future pipe(StreamConsumer<T, dynamic> streamConsumer) {
200 return streamConsumer.consume(this); 173 return streamConsumer.consume(this);
201 } 174 }
202 175
203 /** 176 /**
204 * Chain this stream as the input of the provided [StreamTransformer]. 177 * Chain this stream as the input of the provided [StreamTransformer].
205 * 178 *
206 * Returns the result of [:streamTransformer.bind:] itself. 179 * Returns the result of [:streamTransformer.bind:] itself.
207 */ 180 */
208 Stream transform(StreamTransformer<T, dynamic> streamTransformer) { 181 Stream transform(StreamTransformer<T, dynamic> streamTransformer) {
209 return streamTransformer.bind(this); 182 return streamTransformer.bind(this);
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 } 1098 }
1126 1099
1127 class _StreamOutputSinkWrapper<T> implements StreamSink<T> { 1100 class _StreamOutputSinkWrapper<T> implements StreamSink<T> {
1128 _StreamOutputSink _sink; 1101 _StreamOutputSink _sink;
1129 _StreamOutputSinkWrapper(this._sink); 1102 _StreamOutputSinkWrapper(this._sink);
1130 1103
1131 void add(T data) => _sink._sendData(data); 1104 void add(T data) => _sink._sendData(data);
1132 void signalError(AsyncError error) => _sink._sendError(error); 1105 void signalError(AsyncError error) => _sink._sendError(error);
1133 void close() => _sink._sendDone(); 1106 void close() => _sink._sendDone();
1134 } 1107 }
OLDNEW
« no previous file with comments | « sdk/lib/async/merge_stream.dart ('k') | tests/lib/async/merge_stream_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698