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

Unified Diff: pkg/barback/lib/src/utils.dart

Issue 55983005: Serialize barback assets more efficiently. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 7 years, 1 month 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 | « pkg/barback/lib/src/serialize.dart ('k') | pkg/barback/test/asset_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/utils.dart
diff --git a/pkg/barback/lib/src/utils.dart b/pkg/barback/lib/src/utils.dart
index 53ef822079eeb3e385393454d46c9281ffb96183..38a596eaa0f7bd5da1acd6ccb636b9c796db841d 100644
--- a/pkg/barback/lib/src/utils.dart
+++ b/pkg/barback/lib/src/utils.dart
@@ -196,3 +196,22 @@ Stream futureStream(Future<Stream> future) {
});
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;
+}
« no previous file with comments | « pkg/barback/lib/src/serialize.dart ('k') | pkg/barback/test/asset_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698