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) { |