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 // Controller for creating and adding events to a stream. | 8 // Controller for creating and adding events to a stream. |
9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
10 | 10 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 * A broadcast stream controller is never considered paused. It always | 238 * A broadcast stream controller is never considered paused. It always |
239 * forwards its events to all uncanceled subscriptions, if any, | 239 * forwards its events to all uncanceled subscriptions, if any, |
240 * and let the subscriptions handle their own pausing and buffering. | 240 * and let the subscriptions handle their own pausing and buffering. |
241 */ | 241 */ |
242 bool get isPaused; | 242 bool get isPaused; |
243 | 243 |
244 /** Whether there is a subscriber on the [Stream]. */ | 244 /** Whether there is a subscriber on the [Stream]. */ |
245 bool get hasListener; | 245 bool get hasListener; |
246 | 246 |
247 /** | 247 /** |
248 * Sends a data [event]. | 248 * Send or enqueue an error event. |
249 * | |
250 * Listeners receive this event in a later microtask. | |
251 * | |
252 * Note that a synchronous controller (created by passing true to the `sync` | |
253 * parameter of the `StreamController` constructor) delivers events | |
254 * immediately. Since this behavior violates the contract mentioned here, | |
255 * synchronous controllers should only be used as described in the | |
256 * documentation to ensure that the delivered events always *appear* as if | |
257 * they were delivered in a separate microtask. | |
258 */ | |
259 void add(T event); | |
260 | |
261 /** | |
262 * Sends or enqueues an error event. | |
263 * | 249 * |
264 * If [error] is `null`, it is replaced by a [NullThrownError]. | 250 * If [error] is `null`, it is replaced by a [NullThrownError]. |
265 * | |
266 * Listeners receive this event at a later microtask. This behavior can be | |
267 * overridden by using `sync` controllers. Note, however, that sync | |
268 * controllers have to satisfy the preconditions mentioned in the | |
269 * documentation of the constructors. | |
270 */ | 251 */ |
271 void addError(Object error, [StackTrace stackTrace]); | 252 void addError(Object error, [StackTrace stackTrace]); |
272 | 253 |
273 /** | 254 /** |
274 * Closes the stream. | |
275 * | |
276 * Listeners receive the done event at a later microtask. This behavior can be | |
277 * overridden by using `sync` controllers. Note, however, that sync | |
278 * controllers have to satisfy the preconditions mentioned in the | |
279 * documentation of the constructors. | |
280 */ | |
281 Future close(); | |
282 | |
283 /** | |
284 * Receives events from [source] and puts them into this controller's stream. | 255 * Receives events from [source] and puts them into this controller's stream. |
285 * | 256 * |
286 * Returns a future which completes when the source stream is done. | 257 * Returns a future which completes when the source stream is done. |
287 * | 258 * |
288 * Events must not be added directly to this controller using [add], | 259 * Events must not be added directly to this controller using [add], |
289 * [addError], [close] or [addStream], until the returned future | 260 * [addError], [close] or [addStream], until the returned future |
290 * is complete. | 261 * is complete. |
291 * | 262 * |
292 * Data and error events are forwarded to this controller's stream. A done | 263 * Data and error events are forwarded to this controller's stream. A done |
293 * event on the source will end the `addStream` operation and complete the | 264 * event on the source will end the `addStream` operation and complete the |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 var varData; | 935 var varData; |
965 | 936 |
966 _StreamControllerAddStreamState(_StreamController<T> controller, this.varData, | 937 _StreamControllerAddStreamState(_StreamController<T> controller, this.varData, |
967 Stream source, bool cancelOnError) | 938 Stream source, bool cancelOnError) |
968 : super(controller, source, cancelOnError) { | 939 : super(controller, source, cancelOnError) { |
969 if (controller.isPaused) { | 940 if (controller.isPaused) { |
970 addSubscription.pause(); | 941 addSubscription.pause(); |
971 } | 942 } |
972 } | 943 } |
973 } | 944 } |
OLD | NEW |