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

Unified Diff: lib/src/asset/dart/utils.dart

Issue 2184303002: Make pub strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 5 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/asset/dart/serialize/transform.dart ('k') | lib/src/barback.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/asset/dart/utils.dart
diff --git a/lib/src/asset/dart/utils.dart b/lib/src/asset/dart/utils.dart
index 7baf27c24a92590405fc15377fc794e703853cf5..5b910d8d1e140b12789c4edc54a6550555820f8d 100644
--- a/lib/src/asset/dart/utils.dart
+++ b/lib/src/asset/dart/utils.dart
@@ -4,7 +4,6 @@
/// Functions go in this file as opposed to lib/src/utils.dart if they need to
/// be accessible to the transformer-loading isolate.
-import 'dart:async';
/// A regular expression to match the exception prefix that some exceptions'
/// [Object.toString] values contain.
@@ -16,69 +15,3 @@ final _exceptionPrefix = new RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): ');
/// [toString], so we remove that if it exists.
String getErrorMessage(error) =>
error.toString().replaceFirst(_exceptionPrefix, '');
-
-/// Returns a buffered stream that will emit the same values as the stream
-/// returned by [future] once [future] completes.
-///
-/// If [future] completes to an error, the return value will emit that error and
-/// then close.
-///
-/// If [broadcast] is true, a broadcast stream is returned. This assumes that
-/// the stream returned by [future] will be a broadcast stream as well.
-/// [broadcast] defaults to false.
-Stream futureStream(Future<Stream> future, {bool broadcast: false}) {
- var subscription;
- var controller;
-
- future = future.catchError((e, stackTrace) {
- // Since [controller] is synchronous, it's likely that emitting an error
- // will cause it to be cancelled before we call close.
- if (controller != null) controller.addError(e, stackTrace);
- if (controller != null) controller.close();
- controller = null;
- });
-
- onListen() {
- future.then((stream) {
- if (controller == null) return;
- subscription = stream.listen(
- controller.add,
- onError: controller.addError,
- onDone: controller.close);
- });
- }
-
- onCancel() {
- if (subscription != null) subscription.cancel();
- subscription = null;
- controller = null;
- }
-
- if (broadcast) {
- controller = new StreamController.broadcast(
- sync: true, onListen: onListen, onCancel: onCancel);
- } else {
- controller = new StreamController(
- sync: true, onListen: onListen, onCancel: onCancel);
- }
- 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 | « lib/src/asset/dart/serialize/transform.dart ('k') | lib/src/barback.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698