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

Unified Diff: packages/quiver/lib/src/async/future_stream.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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 | « packages/quiver/lib/src/async/future_group.dart ('k') | packages/quiver/lib/src/async/iteration.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/quiver/lib/src/async/future_stream.dart
diff --git a/packages/quiver/lib/src/async/future_stream.dart b/packages/quiver/lib/src/async/future_stream.dart
index 58b8629e45303640470f6ccfb886e417358c2f02..fc36ad25b1854454db0ec610a54d5c724252e693 100644
--- a/packages/quiver/lib/src/async/future_stream.dart
+++ b/packages/quiver/lib/src/async/future_stream.dart
@@ -14,32 +14,32 @@
part of quiver.async;
-/**
- * A Stream that will emit the same values as the stream returned by [future]
- * once [future] completes.
- *
- * If [future] completes to an error, the return value will emit that error and
- * then close.
- *
- * If [broadcast] is true, this will be a broadcast stream. This assumes that
- * the stream returned by [future] will be a broadcast stream as well.
- * [broadcast] defaults to false.
- *
- * # Example
- *
- * This class is useful when you need to retreive some object via a `Future`,
- * then return a `Stream` from that object:
- *
- * var futureOfStream = getResource().then((resource) => resource.stream);
- * return new FutureStream(futureOfStream);
- */
+/// A Stream that will emit the same values as the stream returned by [future]
+/// once [future] completes.
+///
+/// If [future] completes to an error, the return value will emit that error
+/// and then close.
+///
+/// If [broadcast] is true, this will be a broadcast stream. This assumes that
+/// the stream returned by [future] will be a broadcast stream as well.
+/// [broadcast] defaults to false.
+///
+/// # Example
+///
+/// This class is useful when you need to retreive some object via a `Future`,
+/// then return a `Stream` from that object:
+///
+/// var futureOfStream = getResource().then((resource) => resource.stream);
+/// return new FutureStream(futureOfStream);
class FutureStream<T> extends Stream<T> {
+ static T _identity<T>(T t) => t;
+
Future<Stream<T>> _future;
StreamController<T> _controller;
StreamSubscription _subscription;
FutureStream(Future<Stream<T>> future, {bool broadcast: false}) {
- _future = future.catchError((e, stackTrace) {
+ _future = future.then(_identity, onError: (e, stackTrace) {
// Since [controller] is synchronous, it's likely that emitting an error
// will cause it to be cancelled before we call close.
if (_controller != null) {
« no previous file with comments | « packages/quiver/lib/src/async/future_group.dart ('k') | packages/quiver/lib/src/async/iteration.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698