| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library descriptor.async; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 | |
| 9 import '../../descriptor.dart'; | |
| 10 import '../../scheduled_test.dart'; | |
| 11 | |
| 12 /// A descriptor that wraps a [Future<Descriptor>] and forwards all asynchronous | |
| 13 /// operations to the result of the future. It's designed for use when the full | |
| 14 /// filesystem description isn't known when initializing the schedule. | |
| 15 /// | |
| 16 /// [AsyncDescriptor]s don't support [load], since their names aren't | |
| 17 /// synchronously available. | |
| 18 class AsyncDescriptor extends Descriptor { | |
| 19 /// The [Future] that will complete to the [Descriptor] this descriptor is | |
| 20 /// wrapping. | |
| 21 final Future<Descriptor> future; | |
| 22 | |
| 23 AsyncDescriptor(this.future) | |
| 24 : super('<async descriptor>'); | |
| 25 | |
| 26 Future create([String parent]) => | |
| 27 schedule(() => future.then((entry) => entry.create(parent))); | |
| 28 | |
| 29 Future validate([String parent]) => schedule(() => validateNow(parent)); | |
| 30 | |
| 31 Future validateNow([String parent]) => | |
| 32 future.then((entry) => entry.validateNow(parent)); | |
| 33 | |
| 34 String describe() => "async descriptor"; | |
| 35 } | |
| OLD | NEW |