Chromium Code Reviews| Index: pkg/barback/lib/src/phase.dart |
| diff --git a/pkg/barback/lib/src/phase.dart b/pkg/barback/lib/src/phase.dart |
| index b4efbc7fa44bb3b6950f118848e9056edcb0fd4b..e16f94b7a8e9e3aa7a4a175a7ae0be3ff81484d6 100644 |
| --- a/pkg/barback/lib/src/phase.dart |
| +++ b/pkg/barback/lib/src/phase.dart |
| @@ -141,11 +141,21 @@ class Phase { |
| /// |
| /// Passes their outputs to the next phase. |
| Future _processTransforms() { |
| - var dirtyTransforms = _transforms.where((transform) => transform.isDirty); |
| + // Convert this to a list so we can safely modify _transforms while |
| + // iterating over it. |
| + var dirtyTransforms = _transforms.where((transform) => transform.isDirty) |
| + .toList(); |
| if (dirtyTransforms.isEmpty) return null; |
| - return Future.wait(dirtyTransforms.map((transform) => transform.apply())) |
| - .then((transformOutputs) { |
| + return Future.wait(dirtyTransforms.map((transform) { |
| + if (inputs.containsKey(transform.primary.id)) return transform.apply(); |
| + |
| + // If the primary input for the transform has been removed, get rid of it |
| + // and all its outputs. |
| + _transforms.remove(transform); |
| + return new Future.value( |
| + new TransformOutputs(new AssetSet(), transform.outputs)); |
|
Bob Nystrom
2013/07/17 17:18:26
Smart way to handle this. :)
|
| + })).then((transformOutputs) { |
| // Collect all of the outputs. Since the transforms are run in parallel, |
| // we have to be careful here to ensure that the result is deterministic |
| // and not influenced by the order that transforms complete. |