Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1989)

Unified Diff: dart/sdk/lib/core/load_async.dart

Issue 11784018: Skeleton API for lazy library loading. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698