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

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

Issue 191223004: Add BaseTransform.consumePrimary to barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 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 | « no previous file | pkg/barback/lib/src/phase_input.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/base_transform.dart
diff --git a/pkg/barback/lib/src/base_transform.dart b/pkg/barback/lib/src/base_transform.dart
index d03f4b3a98ceb0cc669e9b9ea420e72fb23fb26f..64945ee72eaac2decbc065e04992a52302e038a1 100644
--- a/pkg/barback/lib/src/base_transform.dart
+++ b/pkg/barback/lib/src/base_transform.dart
@@ -24,6 +24,11 @@ import 'utils.dart';
abstract class BaseTransform {
final TransformNode _node;
+ /// Whether the primary input should be consumed.
+ ///
+ /// This is exposed via [BaseTransformController].
+ bool _consumePrimary = false;
+
/// The controller for the stream of log entries emitted by the transformer.
///
/// This is exposed via [BaseTransformController].
@@ -94,6 +99,17 @@ abstract class BaseTransform {
/// If the asset was created from a [String], this returns its UTF-8 encoding.
Stream<List<int>> readInput(AssetId id) =>
futureStream(getInput(id).then((input) => input.read()));
+
+ /// Consume the primary input so that it doesn't get processed by future
+ /// phases or emitted once processing has finished.
+ ///
+ /// Normally the primary input will automatically be forwarded unless the
+ /// transformer overwrites it by emitting an input with the same id. This
+ /// allows the transformer to tell barback not to forward the primary input
+ /// even if it's not overwritten.
+ void consumePrimary() {
+ _consumePrimary = true;
+ }
}
/// The base class for controllers of subclasses of [BaseTransform].
@@ -104,6 +120,9 @@ abstract class BaseTransformController {
/// The [BaseTransform] controlled by this controller.
final BaseTransform transform;
+ /// Whether the primary input should be consumed.
+ bool get consumePrimary => transform._consumePrimary;
+
/// The stream of log entries emitted by the transformer during a run.
Stream<LogEntry> get onLog => transform._onLogController.stream;
« no previous file with comments | « no previous file | pkg/barback/lib/src/phase_input.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698