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

Unified Diff: sdk/lib/async/stream_controller.dart

Issue 2822173002: Warn when adding something to a closed sink and improve documentation (Closed)
Patch Set: Fix Zone.print only taking a string and update status files. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | sdk/lib/async/stream_transformers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/stream_controller.dart
diff --git a/sdk/lib/async/stream_controller.dart b/sdk/lib/async/stream_controller.dart
index 5e4ec4a621f992db8633bbab9792b5122e581274..721a09a9a82ff44711e04ce8328c78c9b2d004a4 100644
--- a/sdk/lib/async/stream_controller.dart
+++ b/sdk/lib/async/stream_controller.dart
@@ -245,13 +245,42 @@ abstract class StreamController<T> implements StreamSink<T> {
bool get hasListener;
/**
- * Send or enqueue an error event.
+ * Sends a data [event].
+ *
+ * Listeners receive this event in a later microtask.
+ *
+ * Note that a synchronous controller (created by passing true to the `sync`
+ * parameter of the `StreamController` constructor) delivers events
+ * immediately. Since this behavior violates the contract mentioned here,
+ * synchronous controllers should only be used as described in the
+ * documentation to ensure that the delivered events always *appear* as if
+ * they were delivered in a separate microtask.
+ */
+ void add(T event);
+
+ /**
+ * Sends or enqueues an error event.
*
* If [error] is `null`, it is replaced by a [NullThrownError].
+ *
+ * Listeners receive this event at a later microtask. This behavior can be
+ * overridden by using `sync` controllers. Note, however, that sync
+ * controllers have to satisfy the preconditions mentioned in the
+ * documentation of the constructors.
*/
void addError(Object error, [StackTrace stackTrace]);
/**
+ * Closes the stream.
+ *
+ * Listeners receive the done event at a later microtask. This behavior can be
+ * overridden by using `sync` controllers. Note, however, that sync
+ * controllers have to satisfy the preconditions mentioned in the
+ * documentation of the constructors.
+ */
+ Future close();
+
+ /**
* Receives events from [source] and puts them into this controller's stream.
*
* Returns a future which completes when the source stream is done.
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | sdk/lib/async/stream_transformers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698