| 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 * Send or enqueue an error event. | 248 * Sends a data [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. |
| 249 * | 263 * |
| 250 * If [error] is `null`, it is replaced by a [NullThrownError]. | 264 * 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. |
| 251 */ | 270 */ |
| 252 void addError(Object error, [StackTrace stackTrace]); | 271 void addError(Object error, [StackTrace stackTrace]); |
| 253 | 272 |
| 254 /** | 273 /** |
| 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 /** |
| 255 * Receives events from [source] and puts them into this controller's stream. | 284 * Receives events from [source] and puts them into this controller's stream. |
| 256 * | 285 * |
| 257 * Returns a future which completes when the source stream is done. | 286 * Returns a future which completes when the source stream is done. |
| 258 * | 287 * |
| 259 * Events must not be added directly to this controller using [add], | 288 * Events must not be added directly to this controller using [add], |
| 260 * [addError], [close] or [addStream], until the returned future | 289 * [addError], [close] or [addStream], until the returned future |
| 261 * is complete. | 290 * is complete. |
| 262 * | 291 * |
| 263 * Data and error events are forwarded to this controller's stream. A done | 292 * Data and error events are forwarded to this controller's stream. A done |
| 264 * event on the source will end the `addStream` operation and complete the | 293 * 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... |
| 935 var varData; | 964 var varData; |
| 936 | 965 |
| 937 _StreamControllerAddStreamState(_StreamController<T> controller, this.varData, | 966 _StreamControllerAddStreamState(_StreamController<T> controller, this.varData, |
| 938 Stream source, bool cancelOnError) | 967 Stream source, bool cancelOnError) |
| 939 : super(controller, source, cancelOnError) { | 968 : super(controller, source, cancelOnError) { |
| 940 if (controller.isPaused) { | 969 if (controller.isPaused) { |
| 941 addSubscription.pause(); | 970 addSubscription.pause(); |
| 942 } | 971 } |
| 943 } | 972 } |
| 944 } | 973 } |
| OLD | NEW |