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

Unified Diff: sdk/lib/_internal/pub/lib/src/utils.dart

Issue 43143002: Avoid sending needless data between isolates in "pub serve" and "pub build" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge with bleeding edge Created 7 years, 2 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: sdk/lib/_internal/pub/lib/src/utils.dart
diff --git a/sdk/lib/_internal/pub/lib/src/utils.dart b/sdk/lib/_internal/pub/lib/src/utils.dart
index 8a63d52579beec62bf94877919ada0c0be509af6..c17546e7be8489e8c2794764fcf2b92acee9ec17 100644
--- a/sdk/lib/_internal/pub/lib/src/utils.dart
+++ b/sdk/lib/_internal/pub/lib/src/utils.dart
@@ -393,6 +393,25 @@ Stream mergeStreams(Stream stream1, Stream stream2) {
return controller.stream;
}
+/// Returns a [Stream] that will emit the same values as the stream returned by
+/// [callback].
+///
+/// [callback] will only be called when the returned [Stream] gets a subscriber.
+Stream callbackStream(Stream callback()) {
+ var subscription;
+ var controller;
+ controller = new StreamController(onListen: () {
+ subscription = callback().listen(controller.add,
+ onError: controller.addError,
+ onDone: controller.close);
+ },
+ onCancel: () => subscription.cancel(),
+ onPause: () => subscription.pause(),
+ onResume: () => subscription.resume(),
+ sync: true);
+ return controller.stream;
+}
+
/// A regular expression matching a trailing CR character.
final _trailingCR = new RegExp(r"\r$");

Powered by Google App Engine
This is Rietveld 408576698