Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
31ec412
chore(perf): Get watch_group_perf running on Dart2js
mhevery Jan 30, 2014
fc4f055
feat(scope2): Basic implementation of Scope v2
mhevery Jan 25, 2014
e61bc63
feat(Scope): Brand new scope implementation which takes advantage of …
mhevery Feb 4, 2014
a92efe9
fix(change detection): Fix for comparing string by value
vicb Feb 10, 2014
03755a8
refactor: minor code cleanup / fixes
vicb Jan 30, 2014
67f1cd5
chore(scope): remove watchSet API
mhevery Feb 11, 2014
b10d401
feat(scope): Allow expressions on non-scope context
mhevery Feb 11, 2014
05ab378
chore(demo): update to work with new scope
mhevery Feb 11, 2014
c099b44
fix(scope): allow sending emit/broadcast when no on()
mhevery Feb 12, 2014
20ce7c6
feat(zone): Allow escaping of auto-digest mechanism.
mhevery Feb 12, 2014
cf91912
chore(style): code cleanup
vicb Feb 12, 2014
34851bf
fix(balls): ball number can not go below 0
vicb Feb 12, 2014
b5eaeb5
refactor(collection items): Collection items indexes are int
vicb Feb 12, 2014
7188fdd
test(change detector): re-add a previously failing test
vicb Feb 12, 2014
39a2f29
docs(Scope): adding documentation
mhevery Feb 13, 2014
01efda9
chore(scope): clean up style / remove $
mhevery Feb 13, 2014
8b49b6a
refactor(NgAttachAware): wait until all bindings fire.
mhevery Feb 14, 2014
acb8a57
feat(scope): Experimental: Watch once, watch not null expressions
mhevery Feb 14, 2014
30f6322
fix(scope): improve error msg on unstable model
mhevery Feb 14, 2014
0f066cf
fix(binding): call attach when attribute is not specified
mhevery Feb 14, 2014
f9e5a3d
chore(style): formating
mhevery Feb 14, 2014
b4c0373
fixup! fix(binding): call attach when attribute is not specified
mhevery Feb 14, 2014
1eecde4
fix(scope): createChild now requires context
mhevery Feb 14, 2014
6913755
chore(mustach): revert incorect watch/observ optimization
mhevery Feb 14, 2014
21b41dd
fix(watch_group): prevent removed watches from firing
mhevery Feb 14, 2014
f0d9d6c
fix(scope): skip scopes whithot event on broadcast
mhevery Feb 14, 2014
097b298
chore(scope): rename observe to watch(readOnly:true)
mhevery Feb 14, 2014
04911c1
revert(TextChangeListener): remove TextChangeListener support
mhevery Feb 14, 2014
b0dc20f
WIP
mhevery Feb 15, 2014
484a872
fix(ng-event): don't double digest
mhevery Feb 19, 2014
59c4b88
chore(test): re-enable all tests.
mhevery Feb 19, 2014
778733e
fix(compiler): don't wait indefinitly for non-null value on =>!
pavelgj Feb 19, 2014
d6785a6
fix(parser_generator): use parser getter/setter generator instead
pavelgj Feb 19, 2014
f8788ea
hack(scope): ignore nulls in > operator
pavelgj Feb 19, 2014
a6de9ee
fix(introspection): warnings
mhevery Feb 19, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 36 additions & 28 deletions demo/bouncing_balls/bouncy_balls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BallModel {

static _color() {
var color = '#';
for(var i=0; i < 6; i++) {
for(var i = 0; i < 6; i++) {
color += (16 * random.nextDouble()).floor().toRadixString(16);
}
return color;
Expand All @@ -27,58 +27,59 @@ class BallModel {

@NgController(
selector: '[bounce-controller]',
publishAs: 'bounce'
)
publishAs: 'bounce')
class BounceController {
var lastTime = window.performance.now();
var run = true;
var fps = 0;
var digestTime = 0;
var currentDigestTime = 0;
var balls = [];
var zone;
var scope;
final NgZone zone;
final Scope scope;
var ballClassName = 'ball';

BounceController(NgZone this.zone, Scope this.scope) {
BounceController(this.zone, this.scope) {
changeCount(100);
tick();
}

toggleCSS() {
void toggleCSS() {
ballClassName = ballClassName == '' ? 'ball' : '';
}

playPause() {
void playPause() {
run = !run;
if (run) requestAnimationFrame(tick);
}

requestAnimationFrame(fn) {
void requestAnimationFrame(fn) {
window.requestAnimationFrame((_) => zone.run(fn));
}

changeCount(count) {
void changeCount(count) {
while(count > 0) {
balls.add(new BallModel());
count--;
}
while(count < 0) {
while(count < 0 && balls.isNotEmpty) {
balls.removeAt(0);
count++;
}
tick();
}

timeDigest() {
void timeDigest() {
var start = window.performance.now();
scope.$evalAsync(() {
digestTime = (window.performance.now() - start).round();
}, outsideDigest: true);
digestTime = currentDigestTime;
scope.rootScope.domRead(() {
currentDigestTime = window.performance.now() - start;
});
}

tick() {
var now = window.performance.now(),
delay = now - lastTime;
void tick() {
var now = window.performance.now();
var delay = now - lastTime;

fps = (1000/delay).round();
for(var i=0, ii=balls.length; i<ii; i++) {
Expand All @@ -99,27 +100,34 @@ class BounceController {
@NgDirective(
selector: '[ball-position]',
map: const {
"ballPosition": '=>position'
}
)
"ballPosition": '=>position'})
class BallPositionDirective {
Element element;
Scope scope;
BallPositionDirective(Element this.element, Scope this.scope);
final Element element;
final Scope scope;
BallPositionDirective(this.element, this.scope);

set position(BallModel model) {
element.style.backgroundColor = model.color;
scope.$watch(() {
element.style.left = '${model.x + 10}px';
element.style.top = '${model.y + 10}px';
});
scope
..watch('x', (x, _) => element.style.left = '${x + 10}px', context: model, readOnly: true)
..watch('y', (y, _) => element.style.top = '${y + 10}px', context: model, readOnly: true);
}
}

class MyModule extends Module {
MyModule() {
type(BounceController);
type(BallPositionDirective);
value(GetterCache, new GetterCache({
'x': (o) => o.x,
'y': (o) => o.y,
'bounce': (o) => o.bounce,
'fps': (o) => o.fps,
'balls': (o) => o.balls,
'length': (o) => o.length,
'digestTime': (o) => o.digestTime,
'ballClassName': (o) => o.ballClassName
}));
}
}

Expand Down
6 changes: 4 additions & 2 deletions demo/bouncing_balls/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@
</div>

<div>
<div class="fps-bar"><div class="fps" ng-style-width="bounce.fps*4 + 'px'"></div></div>
<div class="fps-bar">
<div class="fps" ng-style-width="bounce.fps*4 + 'px'"></div>
</div>
</div>

{{bounce.fps}} fps. ({{bounce.balls.length}} balls) [{{(1000/bounce.fps).round()}} ms] <br>
{{bounce.fps}} fps. ({{bounce.balls.length}} balls) [{{1000/bounce.fps}} ms] <br>
Digest: {{bounce.digestTime}} ms<br>
<a href ng-click="bounce.changeCount(1)">+1</a>
<a href ng-click="bounce.changeCount(10)">+10</a>
Expand Down
38 changes: 17 additions & 21 deletions demo/bouncing_balls/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,40 @@ packages:
description: analyzer
source: hosted
version: "0.10.5"
analyzer_experimental:
description: analyzer_experimental
source: hosted
version: "0.8.6"
angular:
description:
path: "/usr/local/google/gits/angular-dart/demo/bouncing_balls/../.."
path: "../.."
relative: true
source: path
version: "0.9.3"
version: "0.9.7"
args:
description: args
source: hosted
version: "0.9.0"
browser:
description: browser
source: hosted
version: "0.8.7"
version: "0.9.1"
collection:
description: collection
source: hosted
version: "0.9.0"
version: "0.9.1"
di:
description: di
source: hosted
version: "0.0.24"
version: "0.0.32"
html5lib:
description: html5lib
source: hosted
version: "0.8.7"
version: "0.9.1"
intl:
description: intl
source: hosted
version: "0.8.7"
version: "0.9.1"
logging:
description: logging
source: hosted
version: "0.9.1+1"
meta:
description: meta
source: hosted
version: "0.8.7"
path:
description: path
source: hosted
Expand All @@ -58,24 +50,28 @@ packages:
route_hierarchical:
description: route_hierarchical
source: hosted
version: "0.4.7"
version: "0.4.14"
shadow_dom:
description: shadow_dom
source: hosted
version: "0.9.1"
source_maps:
description: source_maps
source: hosted
version: "0.8.7"
version: "0.9.0"
stack_trace:
description: stack_trace
source: hosted
version: "0.8.7"
version: "0.9.1"
unittest:
description: unittest
source: hosted
version: "0.8.7"
version: "0.10.0"
unmodifiable_collection:
description: unmodifiable_collection
source: hosted
version: "0.9.2"
version: "0.9.2+1"
utf:
description: utf
source: hosted
version: "0.8.7"
version: "0.9.0"
3 changes: 1 addition & 2 deletions demo/helloworld/helloworld.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import 'dart:mirrors';

@NgController(
selector: '[hello-world-controller]',
publishAs: 'ctrl'
)
publishAs: 'ctrl')
class HelloWorldController {
String name = "world";
}
Expand Down
77 changes: 77 additions & 0 deletions demo/helloworld/pubspec.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Generated by pub
# See http://pub.dartlang.org/doc/glossary.html#lockfile
packages:
analyzer:
description: analyzer
source: hosted
version: "0.10.5"
angular:
description:
path: "../.."
relative: true
source: path
version: "0.9.7"
args:
description: args
source: hosted
version: "0.9.0"
browser:
description: browser
source: hosted
version: "0.9.1"
collection:
description: collection
source: hosted
version: "0.9.1"
di:
description: di
source: hosted
version: "0.0.32"
html5lib:
description: html5lib
source: hosted
version: "0.9.1"
intl:
description: intl
source: hosted
version: "0.9.1"
logging:
description: logging
source: hosted
version: "0.9.1+1"
path:
description: path
source: hosted
version: "1.0.0"
perf_api:
description: perf_api
source: hosted
version: "0.0.8"
route_hierarchical:
description: route_hierarchical
source: hosted
version: "0.4.14"
shadow_dom:
description: shadow_dom
source: hosted
version: "0.9.1"
source_maps:
description: source_maps
source: hosted
version: "0.9.0"
stack_trace:
description: stack_trace
source: hosted
version: "0.9.1"
unittest:
description: unittest
source: hosted
version: "0.10.0"
unmodifiable_collection:
description: unmodifiable_collection
source: hosted
version: "0.9.2+1"
utf:
description: utf
source: hosted
version: "0.9.0"
8 changes: 4 additions & 4 deletions demo/todo/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ packages:
path: "../.."
relative: true
source: path
version: "0.9.4"
version: "0.9.7"
args:
description: args
source: hosted
Expand Down Expand Up @@ -50,7 +50,7 @@ packages:
route_hierarchical:
description: route_hierarchical
source: hosted
version: "0.4.10"
version: "0.4.14"
shadow_dom:
description: shadow_dom
source: hosted
Expand All @@ -66,11 +66,11 @@ packages:
unittest:
description: unittest
source: hosted
version: "0.9.3"
version: "0.10.0"
unmodifiable_collection:
description: unmodifiable_collection
source: hosted
version: "0.9.2"
version: "0.9.2+1"
utf:
description: utf
source: hosted
Expand Down
Loading