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

Unified Diff: pkg/polymer/lib/src/loader.dart

Issue 597243002: watch the registration queue and print if it has no progress (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: update changelog Created 6 years, 3 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 | « pkg/polymer/CHANGELOG.md ('k') | pkg/polymer/test/inject_bound_html_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/loader.dart
diff --git a/pkg/polymer/lib/src/loader.dart b/pkg/polymer/lib/src/loader.dart
index 772d54df2cee9397b49e67a8d46bd7ab2238d9d8..ff597adc8e456541a0c5d9dd64f17f3b235a5ec2 100644
--- a/pkg/polymer/lib/src/loader.dart
+++ b/pkg/polymer/lib/src/loader.dart
@@ -68,6 +68,8 @@ void startPolymer(List<Function> initializers, [bool deployMode = true]) {
for (var initializer in initializers) {
initializer();
}
+
+ _watchWaitingFor();
}
/// Configures [initPolymer] making it optimized for deployment to the internet.
@@ -160,3 +162,31 @@ void _initializeLogging() {
// Listen to the polymer logs and print them to the console.
polymerLogger.onRecord.listen((rec) {print(rec);});
}
+
+/// Watches the waitingFor queue and if it fails to make progress then prints
+/// a message to the console.
+void _watchWaitingFor() {
+ int lastWaiting = Polymer.waitingFor.length;
+ int lastAlert;
+ new Timer.periodic(new Duration(seconds: 1), (Timer timer) {
+ var waiting = Polymer.waitingFor;
+ // Done, cancel timer.
+ if (waiting.isEmpty) {
+ timer.cancel();
+ return;
+ }
+ // Made progress, don't alert.
+ if (waiting.length != lastWaiting) {
+ lastWaiting = waiting.length;
+ return;
+ }
+ // Only alert once per waiting state.
+ if (lastAlert == lastWaiting) return;
+ lastAlert = lastWaiting;
+
+ print('No elements registered in a while, but still waiting on '
+ '${waiting.length} elements to be registered. Check that you have a '
+ 'class with an @CustomTag annotation for each of the following tags: '
+ '${waiting.map((e) => "'${e.attributes['name']}'").join(', ')}');
+ });
+}
« no previous file with comments | « pkg/polymer/CHANGELOG.md ('k') | pkg/polymer/test/inject_bound_html_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698