Chromium Code Reviews| Index: pkg/barback/lib/src/asset_cascade.dart |
| diff --git a/pkg/barback/lib/src/asset_cascade.dart b/pkg/barback/lib/src/asset_cascade.dart |
| index 802c8fd6f953a8671848d08eab27a65604490f40..016726efbcd76a12bc1b9eb1e447cb7d6405a206 100644 |
| --- a/pkg/barback/lib/src/asset_cascade.dart |
| +++ b/pkg/barback/lib/src/asset_cascade.dart |
| @@ -84,25 +84,10 @@ class AssetCascade { |
| /// Creates a new [AssetCascade]. |
| /// |
| - /// It loads source assets within [package] using [provider] and then uses |
| - /// [transformerPhases] to generate output files from them. |
| + /// It loads source assets within [package] using [provider]. |
| //TODO(rnystrom): Better way of specifying transformers and their ordering. |
|
Bob Nystrom
2013/08/20 19:08:54
This is TODONE!
nweiz
2013/08/20 21:39:17
Done.
|
| - AssetCascade(this.graph, this.package, |
| - Iterable<Iterable<Transformer>> transformerPhases) { |
| - // Flatten the phases to a list so we can traverse backwards to wire up |
| - // each phase to its next. |
| - var phases = transformerPhases.toList(); |
| - if (phases.isEmpty) phases = [[]]; |
| - |
| - Phase nextPhase = null; |
| - for (var transformers in phases.reversed) { |
| - nextPhase = new Phase(this, transformers.toList(), nextPhase); |
| - nextPhase.onDirty.listen((_) { |
| - _newChanges = true; |
| - _waitForProcess(); |
| - }); |
| - _phases.insert(0, nextPhase); |
| - } |
| + AssetCascade(this.graph, this.package) { |
| + _addPhase(new Phase(this, [])); |
| } |
| /// Gets the asset identified by [id]. |
| @@ -185,11 +170,42 @@ class AssetCascade { |
| }); |
| } |
| + /// Sets this cascade's transformer phases to [transformers]. |
| + void updateTransformers(Iterable<Iterable<Transformer>> transformers) { |
| + transformers = transformers.toList(); |
| + |
| + for (var i = 0; i < transformers.length; i++) { |
| + if (_phases.length > i) { |
| + _phases[i].updateTransformers(transformers[i]); |
| + continue; |
| + } |
| + |
| + _addPhase(_phases.last.addPhase(transformers[i])); |
| + } |
| + |
| + if (transformers.length < _phases.length) { |
| + for (var i = transformers.length; i < _phases.length; i++) { |
| + // TODO(nweiz): actually remove phases rather than emptying them of |
| + // transformers. |
| + _phases[i].updateTransformers([]); |
| + } |
| + } |
| + } |
| + |
| void reportError(BarbackException error) { |
| _accumulatedErrors.add(error); |
| _errorsController.add(error); |
| } |
| + /// Add [phase] to the end of [_phases] and watch its [onDirty] stream. |
| + void _addPhase(Phase phase) { |
| + phase.onDirty.listen((_) { |
| + _newChanges = true; |
| + _waitForProcess(); |
| + }); |
| + _phases.add(phase); |
| + } |
| + |
| /// Starts the build process asynchronously if there is work to be done. |
| /// |
| /// Returns a future that completes with the background processing is done. |