style(ChangeDetection): idiomatic TS

This commit is contained in:
Victor Berchet 2015-06-16 08:47:24 +02:00
parent cdfb635737
commit 598a75ec1c
16 changed files with 128 additions and 228 deletions

View File

@ -5,41 +5,38 @@ import {ChangeDetector} from './interfaces';
import {CHECK_ALWAYS, CHECK_ONCE, CHECKED, DETACHED, ON_PUSH} from './constants'; import {CHECK_ALWAYS, CHECK_ONCE, CHECKED, DETACHED, ON_PUSH} from './constants';
export class AbstractChangeDetector extends ChangeDetector { export class AbstractChangeDetector extends ChangeDetector {
lightDomChildren: List<any>; lightDomChildren: List<any> = [];
shadowDomChildren: List<any>; shadowDomChildren: List<any> = [];
parent: ChangeDetector; parent: ChangeDetector;
mode: string; mode: string = null;
ref: ChangeDetectorRef; ref: ChangeDetectorRef;
constructor() { constructor() {
super(); super();
this.lightDomChildren = [];
this.shadowDomChildren = [];
this.ref = new ChangeDetectorRef(this); this.ref = new ChangeDetectorRef(this);
this.mode = null;
} }
addChild(cd: ChangeDetector) { addChild(cd: ChangeDetector): void {
ListWrapper.push(this.lightDomChildren, cd); ListWrapper.push(this.lightDomChildren, cd);
cd.parent = this; cd.parent = this;
} }
removeChild(cd: ChangeDetector) { ListWrapper.remove(this.lightDomChildren, cd); } removeChild(cd: ChangeDetector): void { ListWrapper.remove(this.lightDomChildren, cd); }
addShadowDomChild(cd: ChangeDetector) { addShadowDomChild(cd: ChangeDetector): void {
ListWrapper.push(this.shadowDomChildren, cd); ListWrapper.push(this.shadowDomChildren, cd);
cd.parent = this; cd.parent = this;
} }
removeShadowDomChild(cd: ChangeDetector) { ListWrapper.remove(this.shadowDomChildren, cd); } removeShadowDomChild(cd: ChangeDetector): void { ListWrapper.remove(this.shadowDomChildren, cd); }
remove() { this.parent.removeChild(this); } remove(): void { this.parent.removeChild(this); }
detectChanges() { this._detectChanges(false); } detectChanges(): void { this._detectChanges(false); }
checkNoChanges() { this._detectChanges(true); } checkNoChanges(): void { this._detectChanges(true); }
_detectChanges(throwOnChange: boolean) { _detectChanges(throwOnChange: boolean): void {
if (this.mode === DETACHED || this.mode === CHECKED) return; if (this.mode === DETACHED || this.mode === CHECKED) return;
this.detectChangesInRecords(throwOnChange); this.detectChangesInRecords(throwOnChange);
@ -53,26 +50,26 @@ export class AbstractChangeDetector extends ChangeDetector {
if (this.mode === CHECK_ONCE) this.mode = CHECKED; if (this.mode === CHECK_ONCE) this.mode = CHECKED;
} }
detectChangesInRecords(throwOnChange: boolean) {} detectChangesInRecords(throwOnChange: boolean): void {}
callOnAllChangesDone() {} callOnAllChangesDone(): void {}
_detectChangesInLightDomChildren(throwOnChange: boolean) { _detectChangesInLightDomChildren(throwOnChange: boolean): void {
var c = this.lightDomChildren; var c = this.lightDomChildren;
for (var i = 0; i < c.length; ++i) { for (var i = 0; i < c.length; ++i) {
c[i]._detectChanges(throwOnChange); c[i]._detectChanges(throwOnChange);
} }
} }
_detectChangesInShadowDomChildren(throwOnChange: boolean) { _detectChangesInShadowDomChildren(throwOnChange: boolean): void {
var c = this.shadowDomChildren; var c = this.shadowDomChildren;
for (var i = 0; i < c.length; ++i) { for (var i = 0; i < c.length; ++i) {
c[i]._detectChanges(throwOnChange); c[i]._detectChanges(throwOnChange);
} }
} }
markAsCheckOnce() { this.mode = CHECK_ONCE; } markAsCheckOnce(): void { this.mode = CHECK_ONCE; }
markPathToRootAsCheckOnce() { markPathToRootAsCheckOnce(): void {
var c: ChangeDetector = this; var c: ChangeDetector = this;
while (isPresent(c) && c.mode != DETACHED) { while (isPresent(c) && c.mode != DETACHED) {
if (c.mode === CHECKED) c.mode = CHECK_ONCE; if (c.mode === CHECKED) c.mode = CHECK_ONCE;

View File

@ -13,50 +13,53 @@ export class BindingRecord {
public elementIndex: number, public propertyName: string, public setter: SetterFn, public elementIndex: number, public propertyName: string, public setter: SetterFn,
public lifecycleEvent: string, public directiveRecord: DirectiveRecord) {} public lifecycleEvent: string, public directiveRecord: DirectiveRecord) {}
callOnChange() { return isPresent(this.directiveRecord) && this.directiveRecord.callOnChange; } callOnChange(): boolean {
return isPresent(this.directiveRecord) && this.directiveRecord.callOnChange;
}
isOnPushChangeDetection() { isOnPushChangeDetection(): boolean {
return isPresent(this.directiveRecord) && this.directiveRecord.isOnPushChangeDetection(); return isPresent(this.directiveRecord) && this.directiveRecord.isOnPushChangeDetection();
} }
isDirective() { return this.mode === DIRECTIVE; } isDirective(): boolean { return this.mode === DIRECTIVE; }
isDirectiveLifecycle() { return this.mode === DIRECTIVE_LIFECYCLE; } isDirectiveLifecycle(): boolean { return this.mode === DIRECTIVE_LIFECYCLE; }
isElement() { return this.mode === ELEMENT; } isElement(): boolean { return this.mode === ELEMENT; }
isTextNode() { return this.mode === TEXT_NODE; } isTextNode(): boolean { return this.mode === TEXT_NODE; }
static createForDirective(ast: AST, propertyName: string, setter: SetterFn, static createForDirective(ast: AST, propertyName: string, setter: SetterFn,
directiveRecord: DirectiveRecord) { directiveRecord: DirectiveRecord): BindingRecord {
return new BindingRecord(DIRECTIVE, 0, ast, 0, propertyName, setter, null, directiveRecord); return new BindingRecord(DIRECTIVE, 0, ast, 0, propertyName, setter, null, directiveRecord);
} }
static createDirectiveOnCheck(directiveRecord: DirectiveRecord) { static createDirectiveOnCheck(directiveRecord: DirectiveRecord): BindingRecord {
return new BindingRecord(DIRECTIVE_LIFECYCLE, 0, null, 0, null, null, "onCheck", return new BindingRecord(DIRECTIVE_LIFECYCLE, 0, null, 0, null, null, "onCheck",
directiveRecord); directiveRecord);
} }
static createDirectiveOnInit(directiveRecord: DirectiveRecord) { static createDirectiveOnInit(directiveRecord: DirectiveRecord): BindingRecord {
return new BindingRecord(DIRECTIVE_LIFECYCLE, 0, null, 0, null, null, "onInit", return new BindingRecord(DIRECTIVE_LIFECYCLE, 0, null, 0, null, null, "onInit",
directiveRecord); directiveRecord);
} }
static createDirectiveOnChange(directiveRecord: DirectiveRecord) { static createDirectiveOnChange(directiveRecord: DirectiveRecord): BindingRecord {
return new BindingRecord(DIRECTIVE_LIFECYCLE, 0, null, 0, null, null, "onChange", return new BindingRecord(DIRECTIVE_LIFECYCLE, 0, null, 0, null, null, "onChange",
directiveRecord); directiveRecord);
} }
static createForElement(ast: AST, elementIndex: number, propertyName: string) { static createForElement(ast: AST, elementIndex: number, propertyName: string): BindingRecord {
return new BindingRecord(ELEMENT, 0, ast, elementIndex, propertyName, null, null, null); return new BindingRecord(ELEMENT, 0, ast, elementIndex, propertyName, null, null, null);
} }
static createForHostProperty(directiveIndex: DirectiveIndex, ast: AST, propertyName: string) { static createForHostProperty(directiveIndex: DirectiveIndex, ast: AST,
propertyName: string): BindingRecord {
return new BindingRecord(ELEMENT, directiveIndex, ast, directiveIndex.elementIndex, return new BindingRecord(ELEMENT, directiveIndex, ast, directiveIndex.elementIndex,
propertyName, null, null, null); propertyName, null, null, null);
} }
static createForTextNode(ast: AST, elementIndex: number) { static createForTextNode(ast: AST, elementIndex: number): BindingRecord {
return new BindingRecord(TEXT_NODE, 0, ast, elementIndex, null, null, null, null); return new BindingRecord(TEXT_NODE, 0, ast, elementIndex, null, null, null, null);
} }
} }

View File

@ -16,14 +16,14 @@ export class ChangeDetectorRef {
/** /**
* Request to check all ON_PUSH ancestors. * Request to check all ON_PUSH ancestors.
*/ */
requestCheck() { this._cd.markPathToRootAsCheckOnce(); } requestCheck(): void { this._cd.markPathToRootAsCheckOnce(); }
/** /**
* Detaches the change detector from the change detector tree. * Detaches the change detector from the change detector tree.
* *
* The detached change detector will not be checked until it is reattached. * The detached change detector will not be checked until it is reattached.
*/ */
detach() { this._cd.mode = DETACHED; } detach(): void { this._cd.mode = DETACHED; }
/** /**
* Reattach the change detector to the change detector tree. * Reattach the change detector to the change detector tree.
@ -32,7 +32,7 @@ export class ChangeDetectorRef {
*checked during the *checked during the
* next change detection run. * next change detection run.
*/ */
reattach() { reattach(): void {
this._cd.mode = CHECK_ALWAYS; this._cd.mode = CHECK_ALWAYS;
this.requestCheck(); this.requestCheck();
} }

View File

@ -13,8 +13,8 @@ import {RecordType, ProtoRecord} from './proto_record';
* replaced with very cheap SELF records. * replaced with very cheap SELF records.
*/ */
export function coalesce(records: List<ProtoRecord>): List<ProtoRecord> { export function coalesce(records: List<ProtoRecord>): List<ProtoRecord> {
var res = ListWrapper.create(); var res: List<ProtoRecord> = ListWrapper.create();
var indexMap = MapWrapper.create(); var indexMap: Map<number, number> = MapWrapper.create();
for (var i = 0; i < records.length; ++i) { for (var i = 0; i < records.length; ++i) {
var r = records[i]; var r = records[i];

View File

@ -16,12 +16,10 @@ export class ExpressionChangedAfterItHasBeenChecked extends BaseException {
export class ChangeDetectionError extends BaseException { export class ChangeDetectionError extends BaseException {
message: string; message: string;
originalException: any;
location: string; location: string;
constructor(proto: ProtoRecord, originalException: any) { constructor(proto: ProtoRecord, public originalException: any) {
super(); super();
this.originalException = originalException;
this.location = proto.expressionAsString; this.location = proto.expressionAsString;
this.message = `${this.originalException} in [${this.location}]`; this.message = `${this.originalException} in [${this.location}]`;
} }

View File

@ -47,17 +47,17 @@ export class ChangeDetector {
parent: ChangeDetector; parent: ChangeDetector;
mode: string; mode: string;
addChild(cd: ChangeDetector) {} addChild(cd: ChangeDetector): void {}
addShadowDomChild(cd: ChangeDetector) {} addShadowDomChild(cd: ChangeDetector): void {}
removeChild(cd: ChangeDetector) {} removeChild(cd: ChangeDetector): void {}
removeShadowDomChild(cd: ChangeDetector) {} removeShadowDomChild(cd: ChangeDetector): void {}
remove() {} remove(): void {}
hydrate(context: any, locals: Locals, directives: any) {} hydrate(context: any, locals: Locals, directives: any): void {}
dehydrate() {} dehydrate(): void {}
markPathToRootAsCheckOnce() {} markPathToRootAsCheckOnce(): void {}
detectChanges() {} detectChanges(): void {}
checkNoChanges() {} checkNoChanges(): void {}
} }
export class ChangeDetectorDefinition { export class ChangeDetectorDefinition {

View File

@ -8,12 +8,12 @@ import {
isPresent isPresent
} from "angular2/src/facade/lang"; } from "angular2/src/facade/lang";
export const TOKEN_TYPE_CHARACTER = 1; const TOKEN_TYPE_CHARACTER = 1;
export const TOKEN_TYPE_IDENTIFIER = 2; const TOKEN_TYPE_IDENTIFIER = 2;
export const TOKEN_TYPE_KEYWORD = 3; const TOKEN_TYPE_KEYWORD = 3;
export const TOKEN_TYPE_STRING = 4; const TOKEN_TYPE_STRING = 4;
export const TOKEN_TYPE_OPERATOR = 5; const TOKEN_TYPE_OPERATOR = 5;
export const TOKEN_TYPE_NUMBER = 6; const TOKEN_TYPE_NUMBER = 6;
@Injectable() @Injectable()
export class Lexer { export class Lexer {
@ -160,24 +160,18 @@ const $NBSP = 160;
export class ScannerError extends BaseException { export class ScannerError extends BaseException {
message: string; constructor(public message) { super(); }
constructor(message) {
super();
this.message = message;
}
toString() { return this.message; } toString(): string { return this.message; }
} }
class _Scanner { class _Scanner {
length: number; length: number;
peek: number; peek: number = 0;
index: number; index: number = -1;
constructor(public input: string) { constructor(public input: string) {
this.length = input.length; this.length = input.length;
this.peek = 0;
this.index = -1;
this.advance(); this.advance();
} }

View File

@ -55,10 +55,9 @@ var INTERPOLATION_REGEXP = RegExpWrapper.create('\\{\\{(.*?)\\}\\}');
@Injectable() @Injectable()
export class Parser { export class Parser {
_lexer: Lexer;
_reflector: Reflector; _reflector: Reflector;
constructor(lexer: Lexer, providedReflector: Reflector = null) {
this._lexer = lexer; constructor(public _lexer: Lexer, providedReflector: Reflector = null) {
this._reflector = isPresent(providedReflector) ? providedReflector : reflector; this._reflector = isPresent(providedReflector) ? providedReflector : reflector;
} }
@ -116,11 +115,9 @@ export class Parser {
} }
class _ParseAST { class _ParseAST {
index: int; index: int = 0;
constructor(public input: string, public location: any, public tokens: List<any>, constructor(public input: string, public location: any, public tokens: List<any>,
public reflector: Reflector, public parseAction: boolean) { public reflector: Reflector, public parseAction: boolean) {}
this.index = 0;
}
peek(offset: int): Token { peek(offset: int): Token {
var i = this.index + offset; var i = this.index + offset;

View File

@ -30,39 +30,23 @@ export class IterableChangesFactory extends PipeFactory {
* @exportedAs angular2/pipes * @exportedAs angular2/pipes
*/ */
export class IterableChanges extends Pipe { export class IterableChanges extends Pipe {
private _collection; private _collection = null;
private _length: int; private _length: int = null;
private _linkedRecords: _DuplicateMap; // Keeps track of the used records at any point in time (during & across `_check()` calls)
private _unlinkedRecords: _DuplicateMap; private _linkedRecords: _DuplicateMap = null;
private _previousItHead: CollectionChangeRecord; // Keeps track of the removed records at any point in time during `_check()` calls.
private _itHead: CollectionChangeRecord; private _unlinkedRecords: _DuplicateMap = null;
private _itTail: CollectionChangeRecord; private _previousItHead: CollectionChangeRecord = null;
private _additionsHead: CollectionChangeRecord; private _itHead: CollectionChangeRecord = null;
private _additionsTail: CollectionChangeRecord; private _itTail: CollectionChangeRecord = null;
private _movesHead: CollectionChangeRecord; private _additionsHead: CollectionChangeRecord = null;
private _movesTail: CollectionChangeRecord; private _additionsTail: CollectionChangeRecord = null;
private _removalsHead: CollectionChangeRecord; private _movesHead: CollectionChangeRecord = null;
private _removalsTail: CollectionChangeRecord; private _movesTail: CollectionChangeRecord = null;
private _removalsHead: CollectionChangeRecord = null;
private _removalsTail: CollectionChangeRecord = null;
constructor() { constructor() { super(); }
super();
this._collection = null;
this._length = null;
/// Keeps track of the used records at any point in time (during & across `_check()` calls)
this._linkedRecords = null;
/// Keeps track of the removed records at any point in time during `_check()` calls.
this._unlinkedRecords = null;
this._previousItHead = null;
this._itHead = null;
this._itTail = null;
this._additionsHead = null;
this._additionsTail = null;
this._movesHead = null;
this._movesTail = null;
this._removalsHead = null;
this._removalsTail = null;
}
static supportsObj(obj): boolean { return isListLikeIterable(obj); } static supportsObj(obj): boolean { return isListLikeIterable(obj); }
@ -496,35 +480,20 @@ export class IterableChanges extends Pipe {
* @exportedAs angular2/pipes * @exportedAs angular2/pipes
*/ */
export class CollectionChangeRecord { export class CollectionChangeRecord {
currentIndex: int; currentIndex: int = null;
previousIndex: int; previousIndex: int = null;
item;
_nextPrevious: CollectionChangeRecord; _nextPrevious: CollectionChangeRecord = null;
_prev: CollectionChangeRecord; _prev: CollectionChangeRecord = null;
_next: CollectionChangeRecord; _next: CollectionChangeRecord = null;
_prevDup: CollectionChangeRecord; _prevDup: CollectionChangeRecord = null;
_nextDup: CollectionChangeRecord; _nextDup: CollectionChangeRecord = null;
_prevRemoved: CollectionChangeRecord; _prevRemoved: CollectionChangeRecord = null;
_nextRemoved: CollectionChangeRecord; _nextRemoved: CollectionChangeRecord = null;
_nextAdded: CollectionChangeRecord; _nextAdded: CollectionChangeRecord = null;
_nextMoved: CollectionChangeRecord; _nextMoved: CollectionChangeRecord = null;
constructor(item) { constructor(public item: any) {}
this.currentIndex = null;
this.previousIndex = null;
this.item = item;
this._nextPrevious = null;
this._prev = null;
this._next = null;
this._prevDup = null;
this._nextDup = null;
this._prevRemoved = null;
this._nextRemoved = null;
this._nextAdded = null;
this._nextMoved = null;
}
toString(): string { toString(): string {
return this.previousIndex === this.currentIndex ? return this.previousIndex === this.currentIndex ?
@ -536,20 +505,15 @@ export class CollectionChangeRecord {
// A linked list of CollectionChangeRecords with the same CollectionChangeRecord.item // A linked list of CollectionChangeRecords with the same CollectionChangeRecord.item
class _DuplicateItemRecordList { class _DuplicateItemRecordList {
_head: CollectionChangeRecord; _head: CollectionChangeRecord = null;
_tail: CollectionChangeRecord; _tail: CollectionChangeRecord = null;
constructor() {
this._head = null;
this._tail = null;
}
/** /**
* Append the record to the list of duplicates. * Append the record to the list of duplicates.
* *
* Note: by design all records in the list of duplicates hold the same value in record.item. * Note: by design all records in the list of duplicates hold the same value in record.item.
*/ */
add(record: CollectionChangeRecord) { add(record: CollectionChangeRecord): void {
if (this._head === null) { if (this._head === null) {
this._head = this._tail = record; this._head = this._tail = record;
record._nextDup = null; record._nextDup = null;
@ -610,8 +574,7 @@ class _DuplicateItemRecordList {
} }
class _DuplicateMap { class _DuplicateMap {
map: Map<any, _DuplicateItemRecordList>; map: Map<any, _DuplicateItemRecordList> = MapWrapper.create();
constructor() { this.map = MapWrapper.create(); }
put(record: CollectionChangeRecord) { put(record: CollectionChangeRecord) {
// todo(vicb) handle corner cases // todo(vicb) handle corner cases

View File

@ -19,28 +19,15 @@ export class KeyValueChangesFactory extends PipeFactory {
* @exportedAs angular2/pipes * @exportedAs angular2/pipes
*/ */
export class KeyValueChanges extends Pipe { export class KeyValueChanges extends Pipe {
private _records: Map<any, any>; private _records: Map<any, any> = MapWrapper.create();
private _mapHead: KVChangeRecord; private _mapHead: KVChangeRecord = null;
private _previousMapHead: KVChangeRecord; private _previousMapHead: KVChangeRecord = null;
private _changesHead: KVChangeRecord; private _changesHead: KVChangeRecord = null;
private _changesTail: KVChangeRecord; private _changesTail: KVChangeRecord = null;
private _additionsHead: KVChangeRecord; private _additionsHead: KVChangeRecord = null;
private _additionsTail: KVChangeRecord; private _additionsTail: KVChangeRecord = null;
private _removalsHead: KVChangeRecord; private _removalsHead: KVChangeRecord = null;
private _removalsTail: KVChangeRecord; private _removalsTail: KVChangeRecord = null;
constructor() {
super();
this._records = MapWrapper.create();
this._mapHead = null;
this._previousMapHead = null;
this._changesHead = null;
this._changesTail = null;
this._additionsHead = null;
this._additionsTail = null;
this._removalsHead = null;
this._removalsTail = null;
}
static supportsObj(obj): boolean { return obj instanceof Map || isJsObject(obj); } static supportsObj(obj): boolean { return obj instanceof Map || isJsObject(obj); }
@ -347,29 +334,17 @@ export class KeyValueChanges extends Pipe {
* @exportedAs angular2/pipes * @exportedAs angular2/pipes
*/ */
export class KVChangeRecord { export class KVChangeRecord {
key; previousValue: any = null;
previousValue; currentValue: any = null;
currentValue;
_nextPrevious: KVChangeRecord; _nextPrevious: KVChangeRecord = null;
_next: KVChangeRecord; _next: KVChangeRecord = null;
_nextAdded: KVChangeRecord; _nextAdded: KVChangeRecord = null;
_nextRemoved: KVChangeRecord; _nextRemoved: KVChangeRecord = null;
_prevRemoved: KVChangeRecord; _prevRemoved: KVChangeRecord = null;
_nextChanged: KVChangeRecord; _nextChanged: KVChangeRecord = null;
constructor(key) { constructor(public key: any) {}
this.key = key;
this.previousValue = null;
this.currentValue = null;
this._nextPrevious = null;
this._next = null;
this._nextAdded = null;
this._nextRemoved = null;
this._prevRemoved = null;
this._nextChanged = null;
}
toString(): string { toString(): string {
return looseIdentical(this.previousValue, this.currentValue) ? return looseIdentical(this.previousValue, this.currentValue) ?

View File

@ -24,11 +24,8 @@ import {Pipe} from './pipe';
* @exportedAs angular2/pipes * @exportedAs angular2/pipes
*/ */
export class LowerCasePipe extends Pipe { export class LowerCasePipe extends Pipe {
_latestValue: string; _latestValue: string = null;
constructor() {
super();
this._latestValue = null;
}
supports(str): boolean { return isString(str); } supports(str): boolean { return isString(str); }
onDestroy(): void { this._latestValue = null; } onDestroy(): void { this._latestValue = null; }

View File

@ -17,11 +17,7 @@ export class NullPipeFactory extends PipeFactory {
* @exportedAs angular2/pipes * @exportedAs angular2/pipes
*/ */
export class NullPipe extends Pipe { export class NullPipe extends Pipe {
called: boolean; called: boolean = false;
constructor() {
super();
this.called = false;
}
static supportsObj(obj): boolean { return isBlank(obj); } static supportsObj(obj): boolean { return isBlank(obj); }

View File

@ -30,22 +30,13 @@ import {ChangeDetectorRef} from '../change_detector_ref';
* @exportedAs angular2/pipes * @exportedAs angular2/pipes
*/ */
export class ObservablePipe extends Pipe { export class ObservablePipe extends Pipe {
_ref: ChangeDetectorRef; _latestValue: Object = null;
_latestReturnedValue: Object = null;
_latestValue: Object; _subscription: Object = null;
_latestReturnedValue: Object; _observable: Observable = null;
_subscription: Object; constructor(public _ref: ChangeDetectorRef) { super(); }
_observable: Observable;
constructor(ref: ChangeDetectorRef) {
super();
this._ref = ref;
this._latestValue = null;
this._latestReturnedValue = null;
this._subscription = null;
this._observable = null;
}
supports(obs): boolean { return ObservableWrapper.isObservable(obs); } supports(obs): boolean { return ObservableWrapper.isObservable(obs); }
@ -106,4 +97,4 @@ export class ObservablePipeFactory extends PipeFactory {
supports(obs): boolean { return ObservableWrapper.isObservable(obs); } supports(obs): boolean { return ObservableWrapper.isObservable(obs); }
create(cdRef): Pipe { return new ObservablePipe(cdRef); } create(cdRef): Pipe { return new ObservablePipe(cdRef); }
} }

View File

@ -29,17 +29,11 @@ import {ChangeDetectorRef} from '../change_detector_ref';
* @exportedAs angular2/pipes * @exportedAs angular2/pipes
*/ */
export class PromisePipe extends Pipe { export class PromisePipe extends Pipe {
_ref: ChangeDetectorRef; _latestValue: Object = null;
_latestValue: Object; _latestReturnedValue: Object = null;
_latestReturnedValue: Object;
_sourcePromise: Promise<any>; _sourcePromise: Promise<any>;
constructor(ref: ChangeDetectorRef) { constructor(public _ref: ChangeDetectorRef) { super(); }
super();
this._ref = ref;
this._latestValue = null;
this._latestReturnedValue = null;
}
supports(promise): boolean { return isPromise(promise); } supports(promise): boolean { return isPromise(promise); }

View File

@ -24,11 +24,8 @@ import {Pipe} from './pipe';
* @exportedAs angular2/pipes * @exportedAs angular2/pipes
*/ */
export class UpperCasePipe extends Pipe { export class UpperCasePipe extends Pipe {
_latestValue: string; _latestValue: string = null;
constructor() {
super();
this._latestValue = null;
}
supports(str): boolean { return isString(str); } supports(str): boolean { return isString(str); }
onDestroy(): void { this._latestValue = null; } onDestroy(): void { this._latestValue = null; }

View File

@ -6,8 +6,6 @@ import {coalesce} from './coalesce';
export {Function as PregenProtoChangeDetectorFactory}; export {Function as PregenProtoChangeDetectorFactory};
export class PregenProtoChangeDetector extends ProtoChangeDetector { export class PregenProtoChangeDetector extends ProtoChangeDetector {
constructor() { super(); }
static isSupported(): boolean { return false; } static isSupported(): boolean { return false; }
instantiate(dispatcher: any): ChangeDetector { instantiate(dispatcher: any): ChangeDetector {