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

Unified Diff: lib/src/lazy_stream.dart

Issue 1870543004: Add typed wrapper functions to delegate classes. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Code review changes Created 4 years, 8 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
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);

Powered by Google App Engine
This is Rietveld 408576698