Skip to content

Commit e9413c8

Browse files
committed
Using the zone.js 0.6
1 parent 7579001 commit e9413c8

File tree

5 files changed

+24
-36
lines changed

5 files changed

+24
-36
lines changed

ng-sample/app/examples/action-bar/action-bar-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Component} from 'angular2/core';
22
import {RouteConfig} from 'angular2/router';
33
import { Page} from "ui/page";
44
import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "../../nativescript-angular/router/ns-router";
5-
import {NS_DIRECTIVES} from "../../nativescript-angular/directives/ns-directives";
5+
import {NS_DIRECTIVES} from "../../nativescript-angular/directives";
66

77
@Component({
88
selector: "first",

ng-sample/app/performance/benchmark.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import {StackLayout} from 'ui/layouts/stack-layout';
22
import {Button} from 'ui/button';
33
import {Label} from 'ui/label';
4-
import {Inject, Component, View} from 'angular2/core';
4+
import {Inject, Component} from 'angular2/core';
55
import {ApplicationRef} from 'angular2/src/core/application_ref';
66
import * as profiling from './profiling';
77

8-
@Component({selector: 'tree', inputs: ['data']})
9-
@View({
10-
directives: [TreeComponent],
11-
template:
12-
`<StackLayout>
8+
@Component({
9+
selector: 'tree',
10+
inputs: ['data'],
11+
directives: [TreeComponent],
12+
template:
13+
`<StackLayout>
1314
<Label [text]="data.value"></Label>
1415
<StackLayout *ngIf="data.right != null">
1516
<tree [data]='data.right'></tree>
@@ -21,15 +22,13 @@ import * as profiling from './profiling';
2122
`
2223
})
2324
class TreeComponent {
24-
data: TreeNode;
25+
data: TreeNode;
2526
}
2627

2728
@Component({
28-
selector: 'benchmark',
29-
})
30-
@View({
29+
selector: 'benchmark',
3130
directives: [TreeComponent],
32-
template: `
31+
template: `
3332
<StackLayout>
3433
<Label text='Benchmark!' fontSize='20' verticalAlignment='center' padding='20'></Label>
3534
<Button text="Baseline test" (tap)="baselineTest(baseline)"></Button>
@@ -88,29 +87,29 @@ export class Benchmark {
8887

8988
private createBaselineDom() {
9089
var values = this.count++ % 2 == 0 ? ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] :
91-
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
90+
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
9291
this.initDataBaseline = buildTree(this.maxDepth, values, 0);
9392
this.appRef.tick();
9493
}
9594

9695
private createNgDom() {
9796
var values = this.count++ % 2 == 0 ? ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] :
98-
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
97+
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
9998
this.initDataNg = buildTree(this.maxDepth, values, 0);
10099
this.appRef.tick();
101100
}
102101
}
103102

104103

105104
export class TreeNode {
106-
value: string;
107-
left: TreeNode;
108-
right: TreeNode;
109-
constructor(value, left, right) {
110-
this.value = value;
111-
this.left = left;
112-
this.right = right;
113-
}
105+
value: string;
106+
left: TreeNode;
107+
right: TreeNode;
108+
constructor(value, left, right) {
109+
this.value = value;
110+
this.left = left;
111+
this.right = right;
112+
}
114113
}
115114

116115
var nodes = 0;

src/nativescript-angular/application.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
//prevent a crash in zone patches. pretend we're node.js
2-
global.process = {};
3-
const oldToString = Object.prototype.toString;
4-
Object.prototype.toString = function() {
5-
return "[object process]";
6-
}
7-
import "zone.js/dist/zone.js"
8-
Object.prototype.toString = oldToString;
9-
delete global.process;
10-
//
11-
//Import globals after the zone, so the latter can't patch everything there.
12-
//The patchables should already be zone-aware already.
131
import 'globals';
2+
import "zone.js/dist/zone-node"
143

154
import 'reflect-metadata';
165
import './polyfills/array';

src/nativescript-angular/renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export class NativeScriptRenderer extends Renderer {
216216

217217
public listen(renderElement: NgView, eventName: string, callback: Function): Function {
218218
traceLog('NativeScriptRenderer.listen: ' + eventName);
219-
let zonedCallback = (<any>global).zone.bind(callback);
219+
let zonedCallback = (<any>global).Zone.current.wrap(callback);
220220
renderElement.on(eventName, zonedCallback);
221221
return () => renderElement.off(eventName, zonedCallback);
222222
}

src/nativescript-angular/router/page-router-outlet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class PageRouterOutlet extends RouterOutlet {
170170
resolve(componentRef)
171171
});
172172

173-
page.on('navigatingFrom', (<any>global).zone.bind((args: NavigatedData) => {
173+
page.on('navigatingFrom', (<any>global).Zone.current.wrap((args: NavigatedData) => {
174174
if (args.isBackNavigation) {
175175
this.location.beginBackPageNavigation();
176176
this.location.back();

0 commit comments

Comments
 (0)