fix(core): remove NgZone_ and use NgZone instead

This commit is contained in:
vsavkin
2015-10-08 13:33:22 -07:00
parent bc8c194665
commit bba0248989
17 changed files with 166 additions and 198 deletions

View File

@ -1,4 +1,4 @@
import {NgZone, NgZone_} from 'angular2/src/core/zone/ng_zone';
import {NgZone} from 'angular2/src/core/zone/ng_zone';
import {Type, isBlank, isPresent, assertionsEnabled} from 'angular2/src/core/facade/lang';
import {bind, Binding, Injector, OpaqueToken} from 'angular2/src/core/di';
import {
@ -112,7 +112,7 @@ export function applicationCommonBindings(): Array<Type | Binding | any[]> {
* Create an Angular zone.
*/
export function createNgZone(): NgZone {
return new NgZone_({enableLongStackTrace: assertionsEnabled()});
return new NgZone({enableLongStackTrace: assertionsEnabled()});
}
var _platform: PlatformRef;
@ -240,7 +240,7 @@ export class PlatformRef_ extends PlatformRef {
try {
injector = this.injector.resolveAndCreateChild(bindings);
exceptionHandler = injector.get(ExceptionHandler);
(<NgZone_>zone).overrideOnErrorHandler((e, s) => exceptionHandler.call(e, s));
zone.overrideOnErrorHandler((e, s) => exceptionHandler.call(e, s));
} catch (e) {
if (isPresent(exceptionHandler)) {
exceptionHandler.call(e, e.stack);

View File

@ -4,7 +4,6 @@ import {NgZone} from 'angular2/src/core/zone/ng_zone';
import {isPresent} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
import {wtfLeave, wtfCreateScope, WtfScopeFn} from '../profile/profile';
import {NgZone_} from "../zone/ng_zone";
/**
* Provides access to explicitly trigger change detection in an application.
@ -72,7 +71,7 @@ export class LifeCycle_ extends LifeCycle {
if (isPresent(changeDetector)) {
this._changeDetectors.push(changeDetector);
}
(<NgZone_>zone).overrideOnTurnDone(() => this.tick());
zone.overrideOnTurnDone(() => this.tick());
}
tick() {

View File

@ -66,8 +66,6 @@ export class ElementRef_ extends ElementRef {
}
get renderView(): RenderViewRef { return (<ViewRef_>this.parentView).render; }
set renderView(value) {
unimplemented();
}
set renderView(value) { unimplemented(); }
get nativeElement(): any { return this._renderer.getNativeElementSync(this); }
}

View File

@ -3,7 +3,7 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {Map, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {CONST, CONST_EXPR} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
import {NgZone, NgZone_} from '../zone/ng_zone';
import {NgZone} from '../zone/ng_zone';
import {PromiseWrapper} from 'angular2/src/core/facade/async';
@ -21,12 +21,11 @@ export class Testability {
constructor(public _ngZone: NgZone) { this._watchAngularEvents(_ngZone); }
_watchAngularEvents(_ngZone: NgZone): void {
(<NgZone_>_ngZone).overrideOnTurnStart(() => { this._isAngularEventPending = true; });
(<NgZone_>_ngZone)
.overrideOnEventDone(() => {
this._isAngularEventPending = false;
this._runCallbacksIfReady();
}, true);
_ngZone.overrideOnTurnStart(() => { this._isAngularEventPending = true; });
_ngZone.overrideOnEventDone(() => {
this._isAngularEventPending = false;
this._runCallbacksIfReady();
}, true);
}
increasePendingRequestCount(): number {

View File

@ -293,7 +293,3 @@ class NgZone {
zoneValues: {'_innerZone': true});
}
}
class NgZone_ extends NgZone {
NgZone_({bool enableLongStackTrace}) : super(enableLongStackTrace: enableLongStackTrace);
}

View File

@ -77,35 +77,7 @@ export interface NgZoneZone extends Zone { _innerZone: boolean; }
* }
* ```
*/
export abstract class NgZone {
/**
* Executes the `fn` function synchronously within the Angular zone and returns value returned by
* the function.
*
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
* outside of the Angular zone (typically started via {@link #runOutsideAngular}).
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* within the Angular zone.
*/
abstract run(fn: () => any): any;
/**
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
* the function.
*
* Running functions via `runOutsideAngular` allows you to escape Angular's zone and do work that
* doesn't trigger Angular change-detection or is subject to Angular's error handling.
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* outside of the Angular zone.
*
* Use {@link #run} to reenter the Angular zone and do work that updates the application model.
*/
abstract runOutsideAngular(fn: () => any): any;
}
export class NgZone_ extends NgZone {
export class NgZone {
_runScope: WtfScopeFn = wtfCreateScope(`NgZone#run()`);
_microtaskScope: WtfScopeFn = wtfCreateScope(`NgZone#microtask()`);
@ -143,7 +115,6 @@ export class NgZone_ extends NgZone {
* enabled in development mode as they significantly impact perf.
*/
constructor({enableLongStackTrace}) {
super();
this._onTurnStart = null;
this._onTurnDone = null;
this._onEventDone = null;
@ -222,6 +193,16 @@ export class NgZone_ extends NgZone {
this._onErrorHandler = normalizeBlank(errorHandler);
}
/**
* Executes the `fn` function synchronously within the Angular zone and returns value returned by
* the function.
*
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
* outside of the Angular zone (typically started via {@link #runOutsideAngular}).
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* within the Angular zone.
*/
run(fn: () => any): any {
if (this._disabled) {
return fn();
@ -235,6 +216,18 @@ export class NgZone_ extends NgZone {
}
}
/**
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
* the function.
*
* Running functions via `runOutsideAngular` allows you to escape Angular's zone and do work that
* doesn't trigger Angular change-detection or is subject to Angular's error handling.
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* outside of the Angular zone.
*
* Use {@link #run} to reenter the Angular zone and do work that updates the application model.
*/
runOutsideAngular(fn: () => any): any {
if (this._disabled) {
return fn();