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

Unified Diff: lib/src/utils.dart

Issue 1155583007: Load SDK sources from compiler_unsupported. (Closed) Base URL: git@github.com:dart-lang/pub_test@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « lib/src/barback/pub_package_provider.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 27d56b438f12b1052104df8f117bb0165d641982..7fb513dcaa9a68fca2312e1a870db8cf86203680 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -598,6 +598,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$");
« no previous file with comments | « lib/src/barback/pub_package_provider.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698