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

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

Issue 11794044: Add Stream.fromIterable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added the test file too. Created 7 years, 11 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 | sdk/lib/async/stream_impl.dart » ('j') | sdk/lib/core/iterable.dart » ('J')
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 68e2588bbab43e4717b253c5116992817a0e4ed8..fc29aa14a96f139546adef4c83bd9bfbc4d856e3 100644
--- a/sdk/lib/async/stream.dart
+++ b/sdk/lib/async/stream.dart
@@ -12,16 +12,23 @@ abstract class Stream<T> {
Stream();
factory Stream.fromFuture(Future<T> future) {
- var controller = new StreamController<T>();
+ _StreamImpl<T> stream = new _MultiStreamImpl<T>();
future.then((value) {
- controller.add(value);
- controller.close();
+ stream._add(value);
+ stream._close();
},
onError: (error) {
- controller.signalError(error);
- controller.close();
+ stream._signalError(error);
+ stream._close();
});
- return controller.stream;
+ return stream;
+ }
+
+ /**
+ * Creates a single-subscription stream that gets its data from [data].
+ */
+ factory Stream.fromIterable(Iterable<T> data) {
+ return new _IterableSingleStreamImpl<T>(data);
}
/**
« no previous file with comments | « no previous file | sdk/lib/async/stream_impl.dart » ('j') | sdk/lib/core/iterable.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698