| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library barback.barback; | 5 library barback.barback; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'asset.dart'; | 9 import 'asset.dart'; |
| 10 import 'asset_id.dart'; | 10 import 'asset_id.dart'; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 : _graph = new PackageGraph(provider); | 66 : _graph = new PackageGraph(provider); |
| 67 | 67 |
| 68 /// Gets the asset identified by [id]. | 68 /// Gets the asset identified by [id]. |
| 69 /// | 69 /// |
| 70 /// If [id] is for a generated or transformed asset, this will wait until | 70 /// If [id] is for a generated or transformed asset, this will wait until |
| 71 /// it has been created and return it. If the asset cannot be found, throws | 71 /// it has been created and return it. If the asset cannot be found, throws |
| 72 /// [AssetNotFoundException]. | 72 /// [AssetNotFoundException]. |
| 73 Future<Asset> getAssetById(AssetId id) { | 73 Future<Asset> getAssetById(AssetId id) { |
| 74 return _graph.getAssetNode(id).then((node) { | 74 return _graph.getAssetNode(id).then((node) { |
| 75 if (node == null) throw new AssetNotFoundException(id); | 75 if (node == null) throw new AssetNotFoundException(id); |
| 76 return node.whenAvailable; | 76 return node.asset; |
| 77 }); | 77 }); |
| 78 } | 78 } |
| 79 | 79 |
| 80 /// Adds [sources] to the graph's known set of source assets. | 80 /// Adds [sources] to the graph's known set of source assets. |
| 81 /// | 81 /// |
| 82 /// Begins applying any transforms that can consume any of the sources. If a | 82 /// Begins applying any transforms that can consume any of the sources. If a |
| 83 /// given source is already known, it is considered modified and all | 83 /// given source is already known, it is considered modified and all |
| 84 /// transforms that use it will be re-applied. | 84 /// transforms that use it will be re-applied. |
| 85 void updateSources(Iterable<AssetId> sources) => | 85 void updateSources(Iterable<AssetId> sources) => |
| 86 _graph.updateSources(sources); | 86 _graph.updateSources(sources); |
| 87 | 87 |
| 88 /// Removes [removed] from the graph's known set of source assets. | 88 /// Removes [removed] from the graph's known set of source assets. |
| 89 void removeSources(Iterable<AssetId> removed) => | 89 void removeSources(Iterable<AssetId> removed) => |
| 90 _graph.removeSources(removed); | 90 _graph.removeSources(removed); |
| 91 } | 91 } |
| OLD | NEW |