Chromium Code Reviews| Index: pkg/barback/lib/src/asset_node.dart |
| diff --git a/pkg/barback/lib/src/asset_node.dart b/pkg/barback/lib/src/asset_node.dart |
| index edc740834e81b14b50f93056d8dcd40519e34a49..95b7d0455b3953926b3c263ed41ca54e6382561a 100644 |
| --- a/pkg/barback/lib/src/asset_node.dart |
| +++ b/pkg/barback/lib/src/asset_node.dart |
| @@ -23,8 +23,11 @@ class AssetNode { |
| /// The transform that created this asset node. |
| /// |
| - /// This is `null` for source assets. |
| - final TransformNode transform; |
| + /// This is `null` for source assets. It can change if the upstream transform |
| + /// that created this asset changes; this change will *not* cause an |
| + /// [onStateChange] event. |
| + TransformNode get transform => _transform; |
| + TransformNode _transform; |
| /// The current state of the asset node. |
| AssetState get state => _state; |
| @@ -110,10 +113,10 @@ class AssetNode { |
| return onStateChange.firstWhere(test); |
| } |
| - AssetNode._(this.id, this.transform) |
| + AssetNode._(this.id, this._transform) |
| : _state = AssetState.DIRTY; |
| - AssetNode._available(Asset asset, this.transform) |
| + AssetNode._available(Asset asset, this._transform) |
| : id = asset.id, |
| _asset = asset, |
| _state = AssetState.AVAILABLE; |
| @@ -134,6 +137,17 @@ class AssetNodeController { |
| AssetNodeController.available(Asset asset, [TransformNode transform]) |
| : node = new AssetNode._available(asset, transform); |
| + /// Creates a controller for a node whose initial state matches the current |
| + /// state of [node]. |
| + AssetNodeController.from(AssetNode node) |
| + : node = new AssetNode._(node.id, node.transform) { |
| + if (node.state.isAvailable) { |
| + setAvailable(node.asset); |
| + } else if (node.state.isRemoved) { |
| + setRemoved(); |
| + } |
| + } |
| + |
| /// Marks the node as [AssetState.DIRTY]. |
| void setDirty() { |
| assert(node._state != AssetState.REMOVED); |
| @@ -165,6 +179,11 @@ class AssetNodeController { |
| node._asset = asset; |
| node._stateChangeController.add(AssetState.AVAILABLE); |
| } |
| + |
| + /// Sets the node's [AssetNode.transform] property. |
|
Bob Nystrom
2013/08/21 21:23:40
Add a bit explaining when/why this will occur.
nweiz
2013/08/22 18:30:49
Done.
|
| + void setTransform(TransformNode transform) { |
| + node._transform = transform; |
| + } |
| } |
| // TODO(nweiz): add an error state. |