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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/polymer/lib/job.dart ('k') | pkg/polymer/lib/polymer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * Exposes helper functionality for interacting with the platform. Similar to
7 * the [Platform] class from dart:html.
8 */
9 // TODO(jmesserly): in Polymer this is a static class called "Platform", but
10 // that conflicts with dart:html. What should we do? Does this functionality
11 // belong in html's Platform instead?
12 library polymer.platform;
13
14 import 'dart:html' show Text, MutationObserver;
15 import 'dart:collection' show Queue;
16 import 'package:observe/src/microtask.dart' show performMicrotaskCheckpoint;
17
18 void flush() {
19 endOfMicrotask(performMicrotaskCheckpoint);
20 }
21
22 int _iterations = 0;
23 final Queue _callbacks = new Queue();
24 final Text _twiddle = () {
25 var twiddle = new Text('');
26 new MutationObserver((x, y) {
27 while (_callbacks.isNotEmpty) {
28 try {
29 _callbacks.removeFirst()();
30 } catch (e) { // Dart note: fire the error async.
31 new Completer().completeError(e);
32 }
33 }
34 }).observe(twiddle, characterData: true);
35 return twiddle;
36 }();
37
38 void endOfMicrotask(void callback()) {
39 _twiddle.text = '${_iterations++}';
40 _callbacks.add(callback);
41 }
OLDNEW
« 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