Chromium Code Reviews| Index: dart/sdk/lib/core/load_async.dart |
| diff --git a/dart/sdk/lib/core/load_async.dart b/dart/sdk/lib/core/load_async.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..06b493d15bf23dec0e7943f3ea472b31a9449f66 |
| --- /dev/null |
| +++ b/dart/sdk/lib/core/load_async.dart |
| @@ -0,0 +1,51 @@ |
| +// 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. |
| + * |
| + * Example usage: |
| + * |
| + * [: |
| + * @DeferLoad('com.example.foo') |
| + * import 'foo.dart' as foo; |
| + * |
| + * void main() { |
| + * foo.method(); // Warning: foo may not have been loaded. |
| + * load('com.example.foo').then(onFooLoaded); |
| + * } |
| + * |
| + * @OnLibraryLoaded('com.example.foo') |
|
kasperl
2013/01/07 12:18:07
Maybe this would be better as WhenLibraryLoaded be
Sean Eagan
2013/01/14 15:57:52
Could the libraryName possibly default to the name
ahe
2013/01/14 16:17:37
It is the name of the library, not the prefix. Thi
|
| + * void onFooLoaded(_) { |
| + * foo.method(); // No warning. |
| + * } |
| + * :] |
| + */ |
|
gbracha
2013/01/07 17:40:15
1. The behavior of this annotation should be prope
|
| +class DeferLoad { |
| + final String libraryName; |
| + |
| + const DeferLoad(this.libraryName); |
| +} |
| + |
| +/** |
| + * Indicates that an element is not called until [libraryName] has |
| + * been loaded. |
| + * |
| + * Applies to library declarations, classes, and functions. |
| + */ |
|
gbracha
2013/01/07 17:40:15
1. The comment says nothing about the semantics of
ahe
2013/01/08 07:19:48
I agree. What do you suggest we do instead?
|
| +class OnLibraryLoaded { |
| + final String libraryName; |
| + |
| + const OnLibraryLoaded(this.libraryName); |
| +} |
| + |
| +/** |
| + * Ensure that [libraryName] has been loaded. |
| + * |
| + * The returned future if this invocation of [load] caused the library |
|
floitsch
2013/02/18 13:22:35
Comment seems incomplete.
|
| + * to be loaded. |
| + */ |
| +external Future<bool> load(String libraryName, {String uri}); |
|
Sean Eagan
2013/01/14 15:57:52
Does this Future throw some sort of error, e.g. Li
ahe
2013/01/14 16:17:37
Yes.
floitsch
2013/02/18 13:22:35
a top-level "load" sounds dangerous to me.
|