X Tutup
Skip to content

Commit bba0248

Browse files
committed
fix(core): remove NgZone_ and use NgZone instead
1 parent bc8c194 commit bba0248

File tree

17 files changed

+166
-198
lines changed

17 files changed

+166
-198
lines changed

modules/angular2/angular2.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ library angular2;
88
export 'package:angular2/core.dart' hide forwardRef, resolveForwardRef, ForwardRefFn;
99
export 'package:angular2/profile.dart';
1010
export 'package:angular2/lifecycle_hooks.dart';
11-
export 'package:angular2/src/core/application_ref.dart';
1211
export 'package:angular2/src/core/application_tokens.dart' hide APP_COMPONENT_REF_PROMISE, APP_ID_RANDOM_BINDING;
1312
export 'package:angular2/src/core/render/dom/dom_tokens.dart';

modules/angular2/core.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export 'package:angular2/src/core/pipes.dart';
88
export 'package:angular2/src/core/facade.dart';
99
// Do not export application for dart. Must import from angular2/bootstrap
1010
//export 'package:angular2/src/core/application.dart';
11-
export 'package:angular2/src/core/application_ref.dart';
11+
export 'package:angular2/src/core/application_ref.dart' hide ApplicationRef_, PlatformRef_;
1212
export 'package:angular2/src/core/services.dart';
1313
export 'package:angular2/src/core/linker.dart';
1414
export 'package:angular2/src/core/lifecycle.dart';

modules/angular2/src/core/application_ref.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {NgZone, NgZone_} from 'angular2/src/core/zone/ng_zone';
1+
import {NgZone} from 'angular2/src/core/zone/ng_zone';
22
import {Type, isBlank, isPresent, assertionsEnabled} from 'angular2/src/core/facade/lang';
33
import {bind, Binding, Injector, OpaqueToken} from 'angular2/src/core/di';
44
import {
@@ -112,7 +112,7 @@ export function applicationCommonBindings(): Array<Type | Binding | any[]> {
112112
* Create an Angular zone.
113113
*/
114114
export function createNgZone(): NgZone {
115-
return new NgZone_({enableLongStackTrace: assertionsEnabled()});
115+
return new NgZone({enableLongStackTrace: assertionsEnabled()});
116116
}
117117

118118
var _platform: PlatformRef;
@@ -240,7 +240,7 @@ export class PlatformRef_ extends PlatformRef {
240240
try {
241241
injector = this.injector.resolveAndCreateChild(bindings);
242242
exceptionHandler = injector.get(ExceptionHandler);
243-
(<NgZone_>zone).overrideOnErrorHandler((e, s) => exceptionHandler.call(e, s));
243+
zone.overrideOnErrorHandler((e, s) => exceptionHandler.call(e, s));
244244
} catch (e) {
245245
if (isPresent(exceptionHandler)) {
246246
exceptionHandler.call(e, e.stack);

modules/angular2/src/core/life_cycle/life_cycle.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {NgZone} from 'angular2/src/core/zone/ng_zone';
44
import {isPresent} from 'angular2/src/core/facade/lang';
55
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
66
import {wtfLeave, wtfCreateScope, WtfScopeFn} from '../profile/profile';
7-
import {NgZone_} from "../zone/ng_zone";
87

98
/**
109
* Provides access to explicitly trigger change detection in an application.
@@ -72,7 +71,7 @@ export class LifeCycle_ extends LifeCycle {
7271
if (isPresent(changeDetector)) {
7372
this._changeDetectors.push(changeDetector);
7473
}
75-
(<NgZone_>zone).overrideOnTurnDone(() => this.tick());
74+
zone.overrideOnTurnDone(() => this.tick());
7675
}
7776

7877
tick() {

modules/angular2/src/core/linker/element_ref.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ export class ElementRef_ extends ElementRef {
6666
}
6767

6868
get renderView(): RenderViewRef { return (<ViewRef_>this.parentView).render; }
69-
set renderView(value) {
70-
unimplemented();
71-
}
69+
set renderView(value) { unimplemented(); }
7270
get nativeElement(): any { return this._renderer.getNativeElementSync(this); }
7371
}

modules/angular2/src/core/testability/testability.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter';
33
import {Map, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
44
import {CONST, CONST_EXPR} from 'angular2/src/core/facade/lang';
55
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
6-
import {NgZone, NgZone_} from '../zone/ng_zone';
6+
import {NgZone} from '../zone/ng_zone';
77
import {PromiseWrapper} from 'angular2/src/core/facade/async';
88

99

@@ -21,12 +21,11 @@ export class Testability {
2121
constructor(public _ngZone: NgZone) { this._watchAngularEvents(_ngZone); }
2222

2323
_watchAngularEvents(_ngZone: NgZone): void {
24-
(<NgZone_>_ngZone).overrideOnTurnStart(() => { this._isAngularEventPending = true; });
25-
(<NgZone_>_ngZone)
26-
.overrideOnEventDone(() => {
27-
this._isAngularEventPending = false;
28-
this._runCallbacksIfReady();
29-
}, true);
24+
_ngZone.overrideOnTurnStart(() => { this._isAngularEventPending = true; });
25+
_ngZone.overrideOnEventDone(() => {
26+
this._isAngularEventPending = false;
27+
this._runCallbacksIfReady();
28+
}, true);
3029
}
3130

3231
increasePendingRequestCount(): number {

modules/angular2/src/core/zone/ng_zone.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,3 @@ class NgZone {
293293
zoneValues: {'_innerZone': true});
294294
}
295295
}
296-
297-
class NgZone_ extends NgZone {
298-
NgZone_({bool enableLongStackTrace}) : super(enableLongStackTrace: enableLongStackTrace);
299-
}

modules/angular2/src/core/zone/ng_zone.ts

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,7 @@ export interface NgZoneZone extends Zone { _innerZone: boolean; }
7777
* }
7878
* ```
7979
*/
80-
export abstract class NgZone {
81-
/**
82-
* Executes the `fn` function synchronously within the Angular zone and returns value returned by
83-
* the function.
84-
*
85-
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
86-
* outside of the Angular zone (typically started via {@link #runOutsideAngular}).
87-
*
88-
* Any future tasks or microtasks scheduled from within this function will continue executing from
89-
* within the Angular zone.
90-
*/
91-
abstract run(fn: () => any): any;
92-
93-
/**
94-
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
95-
* the function.
96-
*
97-
* Running functions via `runOutsideAngular` allows you to escape Angular's zone and do work that
98-
* doesn't trigger Angular change-detection or is subject to Angular's error handling.
99-
*
100-
* Any future tasks or microtasks scheduled from within this function will continue executing from
101-
* outside of the Angular zone.
102-
*
103-
* Use {@link #run} to reenter the Angular zone and do work that updates the application model.
104-
*/
105-
abstract runOutsideAngular(fn: () => any): any;
106-
}
107-
108-
export class NgZone_ extends NgZone {
80+
export class NgZone {
10981
_runScope: WtfScopeFn = wtfCreateScope(`NgZone#run()`);
11082
_microtaskScope: WtfScopeFn = wtfCreateScope(`NgZone#microtask()`);
11183

@@ -143,7 +115,6 @@ export class NgZone_ extends NgZone {
143115
* enabled in development mode as they significantly impact perf.
144116
*/
145117
constructor({enableLongStackTrace}) {
146-
super();
147118
this._onTurnStart = null;
148119
this._onTurnDone = null;
149120
this._onEventDone = null;
@@ -222,6 +193,16 @@ export class NgZone_ extends NgZone {
222193
this._onErrorHandler = normalizeBlank(errorHandler);
223194
}
224195

196+
/**
197+
* Executes the `fn` function synchronously within the Angular zone and returns value returned by
198+
* the function.
199+
*
200+
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
201+
* outside of the Angular zone (typically started via {@link #runOutsideAngular}).
202+
*
203+
* Any future tasks or microtasks scheduled from within this function will continue executing from
204+
* within the Angular zone.
205+
*/
225206
run(fn: () => any): any {
226207
if (this._disabled) {
227208
return fn();
@@ -235,6 +216,18 @@ export class NgZone_ extends NgZone {
235216
}
236217
}
237218

219+
/**
220+
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
221+
* the function.
222+
*
223+
* Running functions via `runOutsideAngular` allows you to escape Angular's zone and do work that
224+
* doesn't trigger Angular change-detection or is subject to Angular's error handling.
225+
*
226+
* Any future tasks or microtasks scheduled from within this function will continue executing from
227+
* outside of the Angular zone.
228+
*
229+
* Use {@link #run} to reenter the Angular zone and do work that updates the application model.
230+
*/
238231
runOutsideAngular(fn: () => any): any {
239232
if (this._disabled) {
240233
return fn();

modules/angular2/src/mock/ng_zone_mock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {NgZone_} from 'angular2/src/core/zone/ng_zone';
1+
import {NgZone} from 'angular2/src/core/zone/ng_zone';
22

3-
export class MockNgZone extends NgZone_ {
3+
export class MockNgZone extends NgZone {
44
_onEventDone: () => void;
55

66
constructor() { super({enableLongStackTrace: false}); }

modules/angular2/src/web_workers/shared/post_message_bus.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptio
77
import {EventEmitter} from 'angular2/src/core/facade/async';
88
import {StringMapWrapper} from 'angular2/src/core/facade/collection';
99
import {Injectable} from "angular2/src/core/di";
10-
import {NgZone, NgZone_} from 'angular2/src/core/zone/ng_zone';
10+
import {NgZone} from 'angular2/src/core/zone/ng_zone';
1111

1212
/**
1313
* A TypeScript implementation of {@link MessageBus} for communicating via JavaScript's
@@ -41,7 +41,7 @@ export class PostMessageBusSink implements MessageBusSink {
4141

4242
attachToZone(zone: NgZone): void {
4343
this._zone = zone;
44-
(<NgZone_>this._zone).overrideOnEventDone(() => this._handleOnEventDone(), false);
44+
this._zone.overrideOnEventDone(() => this._handleOnEventDone(), false);
4545
}
4646

4747
initChannel(channel: string, runInZone: boolean = true): void {

0 commit comments

Comments
 (0)
X Tutup