Chromium Code Reviews| Index: lib/src/lazy_stream.dart |
| diff --git a/lib/src/lazy_stream.dart b/lib/src/lazy_stream.dart |
| index 3ba49531fcf555369a5f28f33b085946d1b8e448..147fa8bd5f2984b66335bc4a78f8b9b8e2648a3b 100644 |
| --- a/lib/src/lazy_stream.dart |
| +++ b/lib/src/lazy_stream.dart |
| @@ -5,6 +5,7 @@ |
| import "dart:async"; |
| import "stream_completer.dart"; |
| +import "delegate/stream.dart"; |
| /// A [Stream] wrapper that forwards to another [Stream] that's initialized |
| /// lazily. |
| @@ -39,9 +40,14 @@ class LazyStream<T> extends Stream<T> { |
| _callback = null; |
| var result = callback(); |
| - Stream stream = result is Future |
| - ? StreamCompleter.fromFuture(result) |
| - : result; |
| + Stream<T> stream; |
| + if (result is Future) { |
| + stream = StreamCompleter.fromFuture(result.then((stream) { |
| + return DelegatingStream.typed/*<T>*/(stream as Stream); |
| + })); |
|
Lasse Reichstein Nielsen
2016/04/08 09:20:29
I still don't like having an async function produc
nweiz
2016/04/11 20:26:16
I still think it's fine :).
|
| + } else { |
| + stream = DelegatingStream.typed/*<T>*/(result as Stream); |
| + } |
| return stream.listen(onData, |
| onError: onError, onDone: onDone, cancelOnError: cancelOnError); |