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); |
+ })); |
+ } else { |
+ stream = DelegatingStream.typed/*<T>*/(result as Stream); |
+ } |
return stream.listen(onData, |
onError: onError, onDone: onDone, cancelOnError: cancelOnError); |