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

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

Issue 48543002: Make Stream.fromIterable only accept a single listen call. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | « no previous file | tests/lib/async/stream_from_iterable_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/stream_impl.dart
diff --git a/sdk/lib/async/stream_impl.dart b/sdk/lib/async/stream_impl.dart
index bf7c8f015c9a51ddf3ba7a3f3a4775fb85237adc..e7cceadf7b0940ace0eb539bb6f4eb679a0c4e84 100644
--- a/sdk/lib/async/stream_impl.dart
+++ b/sdk/lib/async/stream_impl.dart
@@ -488,6 +488,7 @@ typedef _PendingEvents _EventGenerator();
/** Stream that generates its own events. */
class _GeneratedStreamImpl<T> extends _StreamImpl<T> {
final _EventGenerator _pending;
+ bool _isUsed = false;
/**
* Initializes the stream to have only the events provided by a
* [_PendingEvents].
@@ -497,6 +498,8 @@ class _GeneratedStreamImpl<T> extends _StreamImpl<T> {
_GeneratedStreamImpl(this._pending);
StreamSubscription _createSubscription(bool cancelOnError) {
+ if (_isUsed) throw new StateError("Stream has already been listened to.");
+ _isUsed = true;
_BufferingStreamSubscription<T> subscription =
new _BufferingStreamSubscription(cancelOnError);
subscription._setPendingEvents(_pending());
« no previous file with comments | « no previous file | tests/lib/async/stream_from_iterable_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698