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

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

Issue 2864443002: Revert "Throw when adding something to a closed sink and improve documentation." (Closed)
Patch Set: 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 | « CHANGELOG.md ('k') | sdk/lib/async/stream_controller.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/stream.dart
diff --git a/sdk/lib/async/stream.dart b/sdk/lib/async/stream.dart
index 08251204d993dae37ee1a116264a88c7df42c277..27c0ff78371de2cbc433f1dccbd837fac9a9f155 100644
--- a/sdk/lib/async/stream.dart
+++ b/sdk/lib/async/stream.dart
@@ -1462,37 +1462,16 @@ abstract class StreamSubscription<T> {
}
/**
- * A [Sink] that supports adding errors.
- *
- * This makes it suitable for capturing the results of asynchronous
- * computations, which can complete with a value or an error.
- *
- * The [EventSink] has been designed to handle asynchronous events from
- * [Stream]s. See, for example, [Stream.eventTransformed] which uses
- * `EventSink`s to transform events.
+ * An interface that abstracts creation or handling of [Stream] events.
*/
abstract class EventSink<T> implements Sink<T> {
- /**
- * Adds a data [event] to the sink.
- *
- * Must not be called on a closed sink.
- */
+ /** Send a data event to a stream. */
void add(T event);
- /**
- * Adds an [error] to the sink.
- *
- * Must not be called on a closed sink.
- */
- void addError(Object error, [StackTrace stackTrace]);
+ /** Send an async error to a stream. */
+ void addError(Object errorEvent, [StackTrace stackTrace]);
- /**
- * Closes the sink.
- *
- * Calling this method more than once is allowed, but does nothing.
- *
- * Neither [add] nor [addError] must be called after this method.
- */
+ /** Close the sink. No further events can be added after closing. */
void close();
}
@@ -1525,6 +1504,10 @@ class StreamView<T> extends Stream<T> {
* and when no further data need to be added, the [close] method tells the
* consumer to complete its work and shut down.
*
+ * This class is not just a [Sink<Stream>] because it is also combined with
+ * other [Sink] classes, like it's combined with [EventSink] in the
+ * [StreamSink] class.
+ *
* The [Stream.pipe] accepts a `StreamConsumer` and will pass the stream
* to the consumer's [addStream] method. When that completes, it will
* call [close] and then complete its own returned future.
@@ -1566,7 +1549,8 @@ abstract class StreamConsumer<S> {
/**
* A object that accepts stream events both synchronously and asynchronously.
*
- * A [StreamSink] combines the methods from [StreamConsumer] and [EventSink].
+ * A [StreamSink] unifies the asynchronous methods from [StreamConsumer] and
+ * the synchronous methods from [EventSink].
*
* The [EventSink] methods can't be used while the [addStream] is called.
* As soon as the [addStream]'s [Future] completes with a value, the
« no previous file with comments | « CHANGELOG.md ('k') | sdk/lib/async/stream_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698