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

Unified Diff: dart/sdk/lib/async/deferred_load.dart

Issue 11784018: Skeleton API for lazy library loading. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Dummy implementations and tests of basic API, but not functionality Created 7 years, 10 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 | « dart/sdk/lib/async/async_sources.gypi ('k') | dart/tests/lib/async/deferred/deferred_api_library.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bc99a4d354a352c4c74585b27ea173c286b93238
--- /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
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
+ * 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 DeferredLibrary(this.libraryName, {this.uri});
+
+ /**
+ * 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();
+}
« no previous file with comments | « dart/sdk/lib/async/async_sources.gypi ('k') | dart/tests/lib/async/deferred/deferred_api_library.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698