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

Unified Diff: pkg/polymer/lib/platform.dart

Issue 24149003: Port of github.com/polymer/polymer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 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/lib/job.dart ('k') | pkg/polymer/lib/polymer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/platform.dart
diff --git a/pkg/polymer/lib/platform.dart b/pkg/polymer/lib/platform.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5dc5c3e72241ee5b8d6e38242c678e32c350b495
--- /dev/null
+++ b/pkg/polymer/lib/platform.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.
+
+/**
+ * Exposes helper functionality for interacting with the platform. Similar to
+ * the [Platform] class from dart:html.
+ */
+// TODO(jmesserly): in Polymer this is a static class called "Platform", but
+// that conflicts with dart:html. What should we do? Does this functionality
+// belong in html's Platform instead?
+library polymer.platform;
+
+import 'dart:html' show Text, MutationObserver;
+import 'dart:collection' show Queue;
+import 'package:observe/src/microtask.dart' show performMicrotaskCheckpoint;
+
+void flush() {
+ endOfMicrotask(performMicrotaskCheckpoint);
+}
+
+int _iterations = 0;
+final Queue _callbacks = new Queue();
+final Text _twiddle = () {
+ var twiddle = new Text('');
+ new MutationObserver((x, y) {
+ while (_callbacks.isNotEmpty) {
+ try {
+ _callbacks.removeFirst()();
+ } catch (e) { // Dart note: fire the error async.
+ new Completer().completeError(e);
+ }
+ }
+ }).observe(twiddle, characterData: true);
+ return twiddle;
+}();
+
+void endOfMicrotask(void callback()) {
+ _twiddle.text = '${_iterations++}';
+ _callbacks.add(callback);
+}
« no previous file with comments | « pkg/polymer/lib/job.dart ('k') | pkg/polymer/lib/polymer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698