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

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

Issue 243793005: Don't require Transformer methods to return Futures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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: pkg/barback/lib/src/transformer.dart
diff --git a/pkg/barback/lib/src/transformer.dart b/pkg/barback/lib/src/transformer.dart
index 2b9499af2b8fa85bdd97f75f93d0eda202598384..acac1fda8ff872410222ead77a0886c3b7903877 100644
--- a/pkg/barback/lib/src/transformer.dart
+++ b/pkg/barback/lib/src/transformer.dart
@@ -59,15 +59,17 @@ abstract class Transformer {
/// If this is not overridden, defaults to allow any asset whose extension
/// matches one of the ones returned by [allowedExtensions]. If *that* is
/// not overridden, allows all assets.
- Future<bool> isPrimary(AssetId id) {
+ ///
+ /// This may return either a `bool` or a `Future<bool>`.
Bob Nystrom 2014/04/21 22:32:23 Here too. Make it clear that not returning a futur
nweiz 2014/04/21 22:46:24 Done.
+ isPrimary(AssetId id) {
// Allow all files if [primaryExtensions] is not overridden.
- if (allowedExtensions == null) return new Future.value(true);
+ if (allowedExtensions == null) return true;
for (var extension in allowedExtensions.split(" ")) {
- if (id.path.endsWith(extension)) return new Future.value(true);
+ if (id.path.endsWith(extension)) return true;
}
- return new Future.value(false);
+ return false;
}
/// Run this transformer on on the primary input specified by [transform].
@@ -81,7 +83,10 @@ abstract class Transformer {
/// In other words, a Transformer's job is to find all inputs for a
/// transform, starting at the primary input, then generate all output assets
/// and yield them back to the transform.
- Future apply(Transform transform);
+ ///
+ /// This may return a [Future]. If it does, it won't be considered finished
+ /// until that [Future] completes.
Bob Nystrom 2014/04/21 22:32:23 Ditto.
nweiz 2014/04/21 22:46:24 Done.
+ apply(Transform transform);
String toString() => runtimeType.toString().replaceAll("Transformer", "");
}

Powered by Google App Engine
This is Rietveld 408576698