Chromium Code Reviews| 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 /** | |
| 6 * Indicates that loading of [libraryName] is deferred. | |
| 7 * | |
| 8 * Applies to library imports, when used as metadata. | |
| 9 * | |
| 10 * Example usage: | |
| 11 * | |
| 12 * [: | |
| 13 * @lazy | |
|
floitsch
2013/02/18 14:51:02
I would follow some convention (as Kasper suggeste
ahe
2013/02/18 15:20:28
As I implied to Kasper, I'm not keen on setting pr
| |
| 14 * import 'foo.dart' as foo; | |
| 15 * | |
| 16 * const lazy = const DeferredLibrary('com.example.foo'); | |
| 17 * | |
| 18 * void main() { | |
| 19 * foo.method(); // Throws a NoSuchMethodError, foo is not loaded yet. | |
| 20 * lazy.load().then(onFooLoaded); | |
| 21 * } | |
| 22 * | |
| 23 * void onFooLoaded(_) { | |
| 24 * foo.method(); | |
| 25 * } | |
| 26 * :] | |
| 27 */ | |
| 28 class DeferredLibrary { | |
| 29 final String libraryName; | |
| 30 final String uri; | |
| 31 | |
| 32 const DeferredLibrary(this.libraryName, {this.uri}); | |
| 33 | |
| 34 /** | |
| 35 * Ensure that [libraryName] has been loaded. | |
| 36 * | |
| 37 * The value of the returned future is true if this invocation of | |
| 38 * [load] caused the library to be loaded. | |
| 39 */ | |
| 40 external Future<bool> load(); | |
| 41 } | |
| OLD | NEW |