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

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

Issue 2822173002: Warn when adding something to a closed sink and improve documentation (Closed)
Patch Set: Improve documentation (issue 29122). Created 3 years, 8 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
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 // Controller for creating and adding events to a stream. 8 // Controller for creating and adding events to a stream.
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 10
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 * A broadcast stream controller is never considered paused. It always 228 * A broadcast stream controller is never considered paused. It always
229 * forwards its events to all uncanceled subscriptions, if any, 229 * forwards its events to all uncanceled subscriptions, if any,
230 * and let the subscriptions handle their own pausing and buffering. 230 * and let the subscriptions handle their own pausing and buffering.
231 */ 231 */
232 bool get isPaused; 232 bool get isPaused;
233 233
234 /** Whether there is a subscriber on the [Stream]. */ 234 /** Whether there is a subscriber on the [Stream]. */
235 bool get hasListener; 235 bool get hasListener;
236 236
237 /** 237 /**
238 * Send or enqueue an error event. 238 * Sends a data [event].
239 *
240 * Listeners receive this event at a later microtask. This behavior can be
Lasse Reichstein Nielsen 2017/04/26 08:26:19 at -> in (or as). A microtask has a duration, it'
floitsch 2017/05/01 16:46:25 Done.
241 * overridden by using `sync` controllers. Note, however, that sync
Lasse Reichstein Nielsen 2017/04/26 08:26:19 Overridden means something else (you override a me
floitsch 2017/05/01 16:46:25 * Note that a synchronous controller (created by p
242 * controllers have to satisfy the preconditions mentioned in the
243 * documentation of the constructors.
244 */
245 void add(T event);
246
247 /**
248 * Sends or enqueues an error event.
239 * 249 *
240 * If [error] is `null`, it is replaced by a [NullThrownError]. 250 * If [error] is `null`, it is replaced by a [NullThrownError].
251 *
252 * Listeners receive this event at a later microtask. This behavior can be
253 * overridden by using `sync` controllers. Note, however, that sync
254 * controllers have to satisfy the preconditions mentioned in the
255 * documentation of the constructors.
241 */ 256 */
242 void addError(Object error, [StackTrace stackTrace]); 257 void addError(Object error, [StackTrace stackTrace]);
243 258
244 /** 259 /**
260 * Closes the stream.
261 *
262 * Listeners receive the done event at a later microtask. This behavior can be
263 * overridden by using `sync` controllers. Note, however, that sync
264 * controllers have to satisfy the preconditions mentioned in the
265 * documentation of the constructors.
266 */
267 Future close();
268
269 /**
245 * Receives events from [source] and puts them into this controller's stream. 270 * Receives events from [source] and puts them into this controller's stream.
246 * 271 *
247 * Returns a future which completes when the source stream is done. 272 * Returns a future which completes when the source stream is done.
248 * 273 *
249 * Events must not be added directly to this controller using [add], 274 * Events must not be added directly to this controller using [add],
250 * [addError], [close] or [addStream], until the returned future 275 * [addError], [close] or [addStream], until the returned future
251 * is complete. 276 * is complete.
252 * 277 *
253 * Data and error events are forwarded to this controller's stream. A done 278 * Data and error events are forwarded to this controller's stream. A done
254 * event on the source will end the `addStream` operation and complete the 279 * event on the source will end the `addStream` operation and complete the
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 var varData; 950 var varData;
926 951
927 _StreamControllerAddStreamState(_StreamController<T> controller, this.varData, 952 _StreamControllerAddStreamState(_StreamController<T> controller, this.varData,
928 Stream source, bool cancelOnError) 953 Stream source, bool cancelOnError)
929 : super(controller, source, cancelOnError) { 954 : super(controller, source, cancelOnError) {
930 if (controller.isPaused) { 955 if (controller.isPaused) {
931 addSubscription.pause(); 956 addSubscription.pause();
932 } 957 }
933 } 958 }
934 } 959 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698