| 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 code_transformers.src.resolvers; | 5 library code_transformers.src.resolvers; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:barback/barback.dart' show AssetId, Transformer, Transform; | 8 import 'package:barback/barback.dart' show AssetId, Transformer, Transform; |
| 9 | 9 |
| 10 import 'resolver.dart'; | 10 import 'resolver.dart'; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 /// Helper function to make it easy to write an `Transformer.apply` method | 61 /// Helper function to make it easy to write an `Transformer.apply` method |
| 62 /// that automatically gets and releases the resolver. This is typically used | 62 /// that automatically gets and releases the resolver. This is typically used |
| 63 /// as follows: | 63 /// as follows: |
| 64 /// | 64 /// |
| 65 /// Future apply(Transform transform) { | 65 /// Future apply(Transform transform) { |
| 66 /// var entryPoints = ...; // compute entry points | 66 /// var entryPoints = ...; // compute entry points |
| 67 /// return applyToEntryPoints(transform, entryPoints); | 67 /// return applyToEntryPoints(transform, entryPoints); |
| 68 /// } | 68 /// } |
| 69 Future applyToEntryPoints(Transform transform, [List<AssetId> entryPoints]) { | 69 Future applyToEntryPoints(Transform transform, [List<AssetId> entryPoints]) { |
| 70 return resolvers.get(transform, entryPoints).then((resolver) { | 70 return resolvers.get(transform, entryPoints).then((resolver) { |
| 71 return new Future.value(applyResolver(transform, resolver)).then((_) { | 71 return new Future(() => applyResolver(transform, resolver)) |
| 72 resolver.release(); | 72 .whenComplete(() { |
| 73 }); | 73 resolver.release(); |
| 74 }); |
| 74 }); | 75 }); |
| 75 } | 76 } |
| 76 | 77 |
| 77 /// Invoked when the resolver is ready to be processed. | 78 /// Invoked when the resolver is ready to be processed. |
| 78 /// | 79 /// |
| 79 /// Return a Future to indicate when apply is completed. | 80 /// Return a Future to indicate when apply is completed. |
| 80 applyResolver(Transform transform, Resolver resolver); | 81 applyResolver(Transform transform, Resolver resolver); |
| 81 } | 82 } |
| OLD | NEW |