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

Side by Side Diff: sky/examples/fn/lib/component.dart

Issue 973613004: Clean up some Dart idioms in fn (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | sky/examples/fn/lib/fn.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
1 part of fn; 5 part of fn;
2 6
3 List<Component> _dirtyComponents = new List<Component>(); 7 List<Component> _dirtyComponents = new List<Component>();
4 bool _renderScheduled = false; 8 bool _renderScheduled = false;
5 9
6 void _renderDirtyComponents() { 10 void _renderDirtyComponents() {
7 Stopwatch sw = new Stopwatch()..start(); 11 Stopwatch sw = new Stopwatch()..start();
8 12
9 _dirtyComponents.sort((a, b) => a._order - b._order); 13 _dirtyComponents.sort((a, b) => a._order - b._order);
10 for (var comp in _dirtyComponents) { 14 for (var comp in _dirtyComponents) {
(...skipping 12 matching lines...) Expand all
23 if (!_renderScheduled) { 27 if (!_renderScheduled) {
24 _renderScheduled = true; 28 _renderScheduled = true;
25 new Future.microtask(_renderDirtyComponents); 29 new Future.microtask(_renderDirtyComponents);
26 } 30 }
27 } 31 }
28 32
29 abstract class Component extends Node { 33 abstract class Component extends Node {
30 bool _dirty = true; // components begin dirty because they haven't rendered. 34 bool _dirty = true; // components begin dirty because they haven't rendered.
31 Node _rendered = null; 35 Node _rendered = null;
32 bool _removed = false; 36 bool _removed = false;
33 int _order; 37 final int _order;
34 static int _currentOrder = 0; 38 static int _currentOrder = 0;
35 bool _stateful; 39 bool _stateful;
36 static Component _currentlyRendering; 40 static Component _currentlyRendering;
37 41
38 Component({ Object key, bool stateful }) 42 Component({ Object key, bool stateful })
39 : _stateful = stateful != null ? stateful : false, 43 : _stateful = stateful != null ? stateful : false,
40 _order = _currentOrder + 1, 44 _order = _currentOrder + 1,
41 super(key:key); 45 super(key:key);
42 46
43 void willUnmount() {} 47 void willUnmount() {}
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 153
150 new Future.microtask(() { 154 new Future.microtask(() {
151 Stopwatch sw = new Stopwatch()..start(); 155 Stopwatch sw = new Stopwatch()..start();
152 _sync(null, _host, null); 156 _sync(null, _host, null);
153 assert(_root is sky.Node); 157 assert(_root is sky.Node);
154 sw.stop(); 158 sw.stop();
155 print("Initial render: ${sw.elapsedMicroseconds} microseconds"); 159 print("Initial render: ${sw.elapsedMicroseconds} microseconds");
156 }); 160 });
157 } 161 }
158 } 162 }
OLDNEW
« no previous file with comments | « no previous file | sky/examples/fn/lib/fn.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698