Chromium Code Reviews| Index: dart/sdk/lib/async/deferred_load.dart |
| diff --git a/dart/sdk/lib/async/deferred_load.dart b/dart/sdk/lib/async/deferred_load.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cbde986577d5c0012794802d0db5cc4a333788ff |
| --- /dev/null |
| +++ b/dart/sdk/lib/async/deferred_load.dart |
| @@ -0,0 +1,41 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +/** |
| + * Indicates that loading of [libraryName] is deferred. |
| + * |
| + * Applies to library imports, when used as metadata. |
| + * |
| + * Example usage: |
| + * |
| + * [: |
| + * @lazy |
|
kasperl
2013/02/18 13:53:08
So lazy is a user-chosen name now. Neat. Maybe we
ahe
2013/02/18 14:32:11
I would use "lazyFoo", but I'll let other people h
|
| + * import 'foo.dart' as foo; |
| + * |
| + * const lazy = const DeferredLibrary('com.example.foo'); |
| + * |
| + * void main() { |
| + * foo.method(); // Throws a NoSuchMethodError, foo is not loaded yet. |
| + * lazy.load().then(onFooLoaded); |
| + * } |
| + * |
| + * void onFooLoaded(_) { |
| + * foo.method(); |
| + * } |
| + * :] |
| + */ |
| +class DeferredLibrary { |
| + final String libraryName; |
| + final String uri; |
| + |
| + const DeferLoad(this.libraryName, {this.uri}); |
|
kasperl
2013/02/18 13:53:08
DeferredLibrary
ahe
2013/02/18 14:32:11
Done.
|
| + |
| + /** |
| + * Ensure that [libraryName] has been loaded. |
| + * |
| + * The value of the returned future is true if this invocation of |
| + * [load] caused the library to be loaded. |
| + */ |
| + external Future<bool> load(); |
| +} |