| 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..db80a9f9481aff05e7e79d1f9c4ba84b1522cc50 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,14 @@ class AssetNodeController {
|
| node._asset = asset;
|
| node._stateChangeController.add(AssetState.AVAILABLE);
|
| }
|
| +
|
| + /// Sets the node's [AssetNode.transform] property.
|
| + ///
|
| + /// This is used when resolving collisions, where a node will stick around but
|
| + /// a different transform will have created it.
|
| + void setTransform(TransformNode transform) {
|
| + node._transform = transform;
|
| + }
|
| }
|
|
|
| // TODO(nweiz): add an error state.
|
|
|