OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.graph.static_asset_cascade; | 5 library barback.graph.static_asset_cascade; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:async/async.dart'; | 9 import 'package:async/async.dart'; |
10 import 'package:collection/collection.dart'; | 10 import 'package:collection/collection.dart'; |
(...skipping 22 matching lines...) Expand all Loading... |
33 final _sources = new Map<AssetId, Future<AssetNode>>(); | 33 final _sources = new Map<AssetId, Future<AssetNode>>(); |
34 | 34 |
35 StaticAssetCascade(this.graph, this.package); | 35 StaticAssetCascade(this.graph, this.package); |
36 | 36 |
37 Stream<BarbackException> get errors => _errorsController.stream; | 37 Stream<BarbackException> get errors => _errorsController.stream; |
38 final _errorsController = | 38 final _errorsController = |
39 new StreamController<BarbackException>.broadcast(sync: true); | 39 new StreamController<BarbackException>.broadcast(sync: true); |
40 | 40 |
41 final status = NodeStatus.IDLE; | 41 final status = NodeStatus.IDLE; |
42 | 42 |
43 final onLog = new StreamController<LogEntry>.broadcast().stream; | 43 final Stream<LogEntry> onLog = new StreamController.broadcast().stream; |
44 final onStatusChange = new StreamController<NodeStatus>.broadcast().stream; | 44 final Stream<NodeStatus> onStatusChange = |
45 final onAsset = new StreamController<AssetNode>.broadcast().stream; | 45 new StreamController.broadcast().stream; |
| 46 final Stream<AssetNode> onAsset = new StreamController.broadcast().stream; |
46 | 47 |
47 Future<AssetSet> get availableOutputs { | 48 Future<AssetSet> get availableOutputs { |
48 var provider = graph.provider as StaticPackageProvider; | 49 var provider = graph.provider as StaticPackageProvider; |
49 return provider.getAllAssetIds(package).asyncMap(provider.getAsset).toList() | 50 return provider |
| 51 .getAllAssetIds(package) |
| 52 .asyncMap(provider.getAsset) |
| 53 .toList() |
50 .then((assets) => new AssetSet.from(DelegatingList.typed(assets))); | 54 .then((assets) => new AssetSet.from(DelegatingList.typed(assets))); |
51 } | 55 } |
52 | 56 |
53 Future<AssetNode> getAssetNode(AssetId id) { | 57 Future<AssetNode> getAssetNode(AssetId id) { |
54 return _sources.putIfAbsent(id, () { | 58 return _sources.putIfAbsent(id, () { |
55 return DelegatingFuture.typed(graph.provider.getAsset(id).then((asset) { | 59 return DelegatingFuture.typed(graph.provider.getAsset(id).then((asset) { |
56 return new AssetNodeController.available(asset).node; | 60 return new AssetNodeController.available(asset).node; |
57 }).catchError((error, stackTrace) { | 61 }).catchError((error, stackTrace) { |
58 if (error is! AssetNotFoundException) { | 62 if (error is! AssetNotFoundException) { |
59 reportError(new AssetLoadException(id, error, stackTrace)); | 63 reportError(new AssetLoadException(id, error, stackTrace)); |
(...skipping 16 matching lines...) Expand all Loading... |
76 void updateTransformers(Iterable<Iterable> transformersIterable) => | 80 void updateTransformers(Iterable<Iterable> transformersIterable) => |
77 throw new UnsupportedError("Static package $package can't have " | 81 throw new UnsupportedError("Static package $package can't have " |
78 "transformers."); | 82 "transformers."); |
79 | 83 |
80 void forceAllTransforms() {} | 84 void forceAllTransforms() {} |
81 | 85 |
82 void reportError(BarbackException error) => _errorsController.add(error); | 86 void reportError(BarbackException error) => _errorsController.add(error); |
83 | 87 |
84 String toString() => "static cascade for $package"; | 88 String toString() => "static cascade for $package"; |
85 } | 89 } |
OLD | NEW |