From 598a75ec1c837376b95adb3924a116531eec9d08 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Tue, 16 Jun 2015 08:47:24 +0200 Subject: [PATCH] style(ChangeDetection): idiomatic TS --- .../abstract_change_detector.ts | 37 +++---- .../src/change_detection/binding_record.ts | 31 +++--- .../change_detection/change_detector_ref.ts | 6 +- .../angular2/src/change_detection/coalesce.ts | 4 +- .../src/change_detection/exceptions.ts | 4 +- .../src/change_detection/interfaces.ts | 20 ++-- .../src/change_detection/parser/lexer.ts | 26 ++--- .../src/change_detection/parser/parser.ts | 11 +- .../pipes/iterable_changes.ts | 101 ++++++------------ .../pipes/keyvalue_changes.ts | 61 ++++------- .../change_detection/pipes/lowercase_pipe.ts | 7 +- .../src/change_detection/pipes/null_pipe.ts | 6 +- .../change_detection/pipes/observable_pipe.ts | 21 ++-- .../change_detection/pipes/promise_pipe.ts | 12 +-- .../change_detection/pipes/uppercase_pipe.ts | 7 +- .../pregen_proto_change_detector.ts | 2 - 16 files changed, 128 insertions(+), 228 deletions(-) diff --git a/modules/angular2/src/change_detection/abstract_change_detector.ts b/modules/angular2/src/change_detection/abstract_change_detector.ts index 42f3ebaa26..58b4a73828 100644 --- a/modules/angular2/src/change_detection/abstract_change_detector.ts +++ b/modules/angular2/src/change_detection/abstract_change_detector.ts @@ -5,41 +5,38 @@ import {ChangeDetector} from './interfaces'; import {CHECK_ALWAYS, CHECK_ONCE, CHECKED, DETACHED, ON_PUSH} from './constants'; export class AbstractChangeDetector extends ChangeDetector { - lightDomChildren: List; - shadowDomChildren: List; + lightDomChildren: List = []; + shadowDomChildren: List = []; parent: ChangeDetector; - mode: string; + mode: string = null; ref: ChangeDetectorRef; constructor() { super(); - this.lightDomChildren = []; - this.shadowDomChildren = []; this.ref = new ChangeDetectorRef(this); - this.mode = null; } - addChild(cd: ChangeDetector) { + addChild(cd: ChangeDetector): void { ListWrapper.push(this.lightDomChildren, cd); 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); 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; this.detectChangesInRecords(throwOnChange); @@ -53,26 +50,26 @@ export class AbstractChangeDetector extends ChangeDetector { if (this.mode === CHECK_ONCE) this.mode = CHECKED; } - detectChangesInRecords(throwOnChange: boolean) {} - callOnAllChangesDone() {} + detectChangesInRecords(throwOnChange: boolean): void {} + callOnAllChangesDone(): void {} - _detectChangesInLightDomChildren(throwOnChange: boolean) { + _detectChangesInLightDomChildren(throwOnChange: boolean): void { var c = this.lightDomChildren; for (var i = 0; i < c.length; ++i) { c[i]._detectChanges(throwOnChange); } } - _detectChangesInShadowDomChildren(throwOnChange: boolean) { + _detectChangesInShadowDomChildren(throwOnChange: boolean): void { var c = this.shadowDomChildren; for (var i = 0; i < c.length; ++i) { c[i]._detectChanges(throwOnChange); } } - markAsCheckOnce() { this.mode = CHECK_ONCE; } + markAsCheckOnce(): void { this.mode = CHECK_ONCE; } - markPathToRootAsCheckOnce() { + markPathToRootAsCheckOnce(): void { var c: ChangeDetector = this; while (isPresent(c) && c.mode != DETACHED) { if (c.mode === CHECKED) c.mode = CHECK_ONCE; diff --git a/modules/angular2/src/change_detection/binding_record.ts b/modules/angular2/src/change_detection/binding_record.ts index 616e4d02be..ca67656c09 100644 --- a/modules/angular2/src/change_detection/binding_record.ts +++ b/modules/angular2/src/change_detection/binding_record.ts @@ -13,50 +13,53 @@ export class BindingRecord { public elementIndex: number, public propertyName: string, public setter: SetterFn, 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(); } - 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, - directiveRecord: DirectiveRecord) { + directiveRecord: DirectiveRecord): BindingRecord { 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", directiveRecord); } - static createDirectiveOnInit(directiveRecord: DirectiveRecord) { + static createDirectiveOnInit(directiveRecord: DirectiveRecord): BindingRecord { return new BindingRecord(DIRECTIVE_LIFECYCLE, 0, null, 0, null, null, "onInit", directiveRecord); } - static createDirectiveOnChange(directiveRecord: DirectiveRecord) { + static createDirectiveOnChange(directiveRecord: DirectiveRecord): BindingRecord { return new BindingRecord(DIRECTIVE_LIFECYCLE, 0, null, 0, null, null, "onChange", 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); } - 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, 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); } -} \ No newline at end of file +} diff --git a/modules/angular2/src/change_detection/change_detector_ref.ts b/modules/angular2/src/change_detection/change_detector_ref.ts index 735e319d54..bd6262eb65 100644 --- a/modules/angular2/src/change_detection/change_detector_ref.ts +++ b/modules/angular2/src/change_detection/change_detector_ref.ts @@ -16,14 +16,14 @@ export class ChangeDetectorRef { /** * 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. * * 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. @@ -32,7 +32,7 @@ export class ChangeDetectorRef { *checked during the * next change detection run. */ - reattach() { + reattach(): void { this._cd.mode = CHECK_ALWAYS; this.requestCheck(); } diff --git a/modules/angular2/src/change_detection/coalesce.ts b/modules/angular2/src/change_detection/coalesce.ts index f1d58205a0..faf37caf73 100644 --- a/modules/angular2/src/change_detection/coalesce.ts +++ b/modules/angular2/src/change_detection/coalesce.ts @@ -13,8 +13,8 @@ import {RecordType, ProtoRecord} from './proto_record'; * replaced with very cheap SELF records. */ export function coalesce(records: List): List { - var res = ListWrapper.create(); - var indexMap = MapWrapper.create(); + var res: List = ListWrapper.create(); + var indexMap: Map = MapWrapper.create(); for (var i = 0; i < records.length; ++i) { var r = records[i]; diff --git a/modules/angular2/src/change_detection/exceptions.ts b/modules/angular2/src/change_detection/exceptions.ts index fbc34d8e7a..38aa43202f 100644 --- a/modules/angular2/src/change_detection/exceptions.ts +++ b/modules/angular2/src/change_detection/exceptions.ts @@ -16,12 +16,10 @@ export class ExpressionChangedAfterItHasBeenChecked extends BaseException { export class ChangeDetectionError extends BaseException { message: string; - originalException: any; location: string; - constructor(proto: ProtoRecord, originalException: any) { + constructor(proto: ProtoRecord, public originalException: any) { super(); - this.originalException = originalException; this.location = proto.expressionAsString; this.message = `${this.originalException} in [${this.location}]`; } diff --git a/modules/angular2/src/change_detection/interfaces.ts b/modules/angular2/src/change_detection/interfaces.ts index 59e1fda40e..bc78fcefd5 100644 --- a/modules/angular2/src/change_detection/interfaces.ts +++ b/modules/angular2/src/change_detection/interfaces.ts @@ -47,17 +47,17 @@ export class ChangeDetector { parent: ChangeDetector; mode: string; - addChild(cd: ChangeDetector) {} - addShadowDomChild(cd: ChangeDetector) {} - removeChild(cd: ChangeDetector) {} - removeShadowDomChild(cd: ChangeDetector) {} - remove() {} - hydrate(context: any, locals: Locals, directives: any) {} - dehydrate() {} - markPathToRootAsCheckOnce() {} + addChild(cd: ChangeDetector): void {} + addShadowDomChild(cd: ChangeDetector): void {} + removeChild(cd: ChangeDetector): void {} + removeShadowDomChild(cd: ChangeDetector): void {} + remove(): void {} + hydrate(context: any, locals: Locals, directives: any): void {} + dehydrate(): void {} + markPathToRootAsCheckOnce(): void {} - detectChanges() {} - checkNoChanges() {} + detectChanges(): void {} + checkNoChanges(): void {} } export class ChangeDetectorDefinition { diff --git a/modules/angular2/src/change_detection/parser/lexer.ts b/modules/angular2/src/change_detection/parser/lexer.ts index 66d33c3e16..359b477e71 100644 --- a/modules/angular2/src/change_detection/parser/lexer.ts +++ b/modules/angular2/src/change_detection/parser/lexer.ts @@ -8,12 +8,12 @@ import { isPresent } from "angular2/src/facade/lang"; -export const TOKEN_TYPE_CHARACTER = 1; -export const TOKEN_TYPE_IDENTIFIER = 2; -export const TOKEN_TYPE_KEYWORD = 3; -export const TOKEN_TYPE_STRING = 4; -export const TOKEN_TYPE_OPERATOR = 5; -export const TOKEN_TYPE_NUMBER = 6; +const TOKEN_TYPE_CHARACTER = 1; +const TOKEN_TYPE_IDENTIFIER = 2; +const TOKEN_TYPE_KEYWORD = 3; +const TOKEN_TYPE_STRING = 4; +const TOKEN_TYPE_OPERATOR = 5; +const TOKEN_TYPE_NUMBER = 6; @Injectable() export class Lexer { @@ -160,24 +160,18 @@ const $NBSP = 160; export class ScannerError extends BaseException { - message: string; - constructor(message) { - super(); - this.message = message; - } + constructor(public message) { super(); } - toString() { return this.message; } + toString(): string { return this.message; } } class _Scanner { length: number; - peek: number; - index: number; + peek: number = 0; + index: number = -1; constructor(public input: string) { this.length = input.length; - this.peek = 0; - this.index = -1; this.advance(); } diff --git a/modules/angular2/src/change_detection/parser/parser.ts b/modules/angular2/src/change_detection/parser/parser.ts index 2452c8b6ac..a6446446ca 100644 --- a/modules/angular2/src/change_detection/parser/parser.ts +++ b/modules/angular2/src/change_detection/parser/parser.ts @@ -55,10 +55,9 @@ var INTERPOLATION_REGEXP = RegExpWrapper.create('\\{\\{(.*?)\\}\\}'); @Injectable() export class Parser { - _lexer: Lexer; _reflector: Reflector; - constructor(lexer: Lexer, providedReflector: Reflector = null) { - this._lexer = lexer; + + constructor(public _lexer: Lexer, providedReflector: Reflector = null) { this._reflector = isPresent(providedReflector) ? providedReflector : reflector; } @@ -116,11 +115,9 @@ export class Parser { } class _ParseAST { - index: int; + index: int = 0; constructor(public input: string, public location: any, public tokens: List, - public reflector: Reflector, public parseAction: boolean) { - this.index = 0; - } + public reflector: Reflector, public parseAction: boolean) {} peek(offset: int): Token { var i = this.index + offset; diff --git a/modules/angular2/src/change_detection/pipes/iterable_changes.ts b/modules/angular2/src/change_detection/pipes/iterable_changes.ts index 767d3f0314..a18db114e7 100644 --- a/modules/angular2/src/change_detection/pipes/iterable_changes.ts +++ b/modules/angular2/src/change_detection/pipes/iterable_changes.ts @@ -30,39 +30,23 @@ export class IterableChangesFactory extends PipeFactory { * @exportedAs angular2/pipes */ export class IterableChanges extends Pipe { - private _collection; - private _length: int; - private _linkedRecords: _DuplicateMap; - private _unlinkedRecords: _DuplicateMap; - private _previousItHead: CollectionChangeRecord; - private _itHead: CollectionChangeRecord; - private _itTail: CollectionChangeRecord; - private _additionsHead: CollectionChangeRecord; - private _additionsTail: CollectionChangeRecord; - private _movesHead: CollectionChangeRecord; - private _movesTail: CollectionChangeRecord; - private _removalsHead: CollectionChangeRecord; - private _removalsTail: CollectionChangeRecord; + private _collection = null; + private _length: int = null; + // Keeps track of the used records at any point in time (during & across `_check()` calls) + private _linkedRecords: _DuplicateMap = null; + // Keeps track of the removed records at any point in time during `_check()` calls. + private _unlinkedRecords: _DuplicateMap = null; + private _previousItHead: CollectionChangeRecord = null; + private _itHead: CollectionChangeRecord = null; + private _itTail: CollectionChangeRecord = null; + private _additionsHead: CollectionChangeRecord = null; + private _additionsTail: CollectionChangeRecord = null; + private _movesHead: CollectionChangeRecord = null; + private _movesTail: CollectionChangeRecord = null; + private _removalsHead: CollectionChangeRecord = null; + private _removalsTail: CollectionChangeRecord = null; - constructor() { - 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; - } + constructor() { super(); } static supportsObj(obj): boolean { return isListLikeIterable(obj); } @@ -496,35 +480,20 @@ export class IterableChanges extends Pipe { * @exportedAs angular2/pipes */ export class CollectionChangeRecord { - currentIndex: int; - previousIndex: int; - item; + currentIndex: int = null; + previousIndex: int = null; - _nextPrevious: CollectionChangeRecord; - _prev: CollectionChangeRecord; - _next: CollectionChangeRecord; - _prevDup: CollectionChangeRecord; - _nextDup: CollectionChangeRecord; - _prevRemoved: CollectionChangeRecord; - _nextRemoved: CollectionChangeRecord; - _nextAdded: CollectionChangeRecord; - _nextMoved: CollectionChangeRecord; + _nextPrevious: CollectionChangeRecord = null; + _prev: CollectionChangeRecord = null; + _next: CollectionChangeRecord = null; + _prevDup: CollectionChangeRecord = null; + _nextDup: CollectionChangeRecord = null; + _prevRemoved: CollectionChangeRecord = null; + _nextRemoved: CollectionChangeRecord = null; + _nextAdded: CollectionChangeRecord = null; + _nextMoved: CollectionChangeRecord = null; - constructor(item) { - 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; - } + constructor(public item: any) {} toString(): string { return this.previousIndex === this.currentIndex ? @@ -536,20 +505,15 @@ export class CollectionChangeRecord { // A linked list of CollectionChangeRecords with the same CollectionChangeRecord.item class _DuplicateItemRecordList { - _head: CollectionChangeRecord; - _tail: CollectionChangeRecord; - - constructor() { - this._head = null; - this._tail = null; - } + _head: CollectionChangeRecord = null; + _tail: CollectionChangeRecord = null; /** * 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. */ - add(record: CollectionChangeRecord) { + add(record: CollectionChangeRecord): void { if (this._head === null) { this._head = this._tail = record; record._nextDup = null; @@ -610,8 +574,7 @@ class _DuplicateItemRecordList { } class _DuplicateMap { - map: Map; - constructor() { this.map = MapWrapper.create(); } + map: Map = MapWrapper.create(); put(record: CollectionChangeRecord) { // todo(vicb) handle corner cases diff --git a/modules/angular2/src/change_detection/pipes/keyvalue_changes.ts b/modules/angular2/src/change_detection/pipes/keyvalue_changes.ts index 602da82bc4..ce98ef869d 100644 --- a/modules/angular2/src/change_detection/pipes/keyvalue_changes.ts +++ b/modules/angular2/src/change_detection/pipes/keyvalue_changes.ts @@ -19,28 +19,15 @@ export class KeyValueChangesFactory extends PipeFactory { * @exportedAs angular2/pipes */ export class KeyValueChanges extends Pipe { - private _records: Map; - private _mapHead: KVChangeRecord; - private _previousMapHead: KVChangeRecord; - private _changesHead: KVChangeRecord; - private _changesTail: KVChangeRecord; - private _additionsHead: KVChangeRecord; - private _additionsTail: KVChangeRecord; - private _removalsHead: KVChangeRecord; - private _removalsTail: KVChangeRecord; - - 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; - } + private _records: Map = MapWrapper.create(); + private _mapHead: KVChangeRecord = null; + private _previousMapHead: KVChangeRecord = null; + private _changesHead: KVChangeRecord = null; + private _changesTail: KVChangeRecord = null; + private _additionsHead: KVChangeRecord = null; + private _additionsTail: KVChangeRecord = null; + private _removalsHead: KVChangeRecord = null; + private _removalsTail: KVChangeRecord = null; static supportsObj(obj): boolean { return obj instanceof Map || isJsObject(obj); } @@ -347,29 +334,17 @@ export class KeyValueChanges extends Pipe { * @exportedAs angular2/pipes */ export class KVChangeRecord { - key; - previousValue; - currentValue; + previousValue: any = null; + currentValue: any = null; - _nextPrevious: KVChangeRecord; - _next: KVChangeRecord; - _nextAdded: KVChangeRecord; - _nextRemoved: KVChangeRecord; - _prevRemoved: KVChangeRecord; - _nextChanged: KVChangeRecord; + _nextPrevious: KVChangeRecord = null; + _next: KVChangeRecord = null; + _nextAdded: KVChangeRecord = null; + _nextRemoved: KVChangeRecord = null; + _prevRemoved: KVChangeRecord = null; + _nextChanged: KVChangeRecord = null; - constructor(key) { - 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; - } + constructor(public key: any) {} toString(): string { return looseIdentical(this.previousValue, this.currentValue) ? diff --git a/modules/angular2/src/change_detection/pipes/lowercase_pipe.ts b/modules/angular2/src/change_detection/pipes/lowercase_pipe.ts index 5df0190f15..578102508c 100644 --- a/modules/angular2/src/change_detection/pipes/lowercase_pipe.ts +++ b/modules/angular2/src/change_detection/pipes/lowercase_pipe.ts @@ -24,11 +24,8 @@ import {Pipe} from './pipe'; * @exportedAs angular2/pipes */ export class LowerCasePipe extends Pipe { - _latestValue: string; - constructor() { - super(); - this._latestValue = null; - } + _latestValue: string = null; + supports(str): boolean { return isString(str); } onDestroy(): void { this._latestValue = null; } diff --git a/modules/angular2/src/change_detection/pipes/null_pipe.ts b/modules/angular2/src/change_detection/pipes/null_pipe.ts index bebb3c86fe..e7e037ac7e 100644 --- a/modules/angular2/src/change_detection/pipes/null_pipe.ts +++ b/modules/angular2/src/change_detection/pipes/null_pipe.ts @@ -17,11 +17,7 @@ export class NullPipeFactory extends PipeFactory { * @exportedAs angular2/pipes */ export class NullPipe extends Pipe { - called: boolean; - constructor() { - super(); - this.called = false; - } + called: boolean = false; static supportsObj(obj): boolean { return isBlank(obj); } diff --git a/modules/angular2/src/change_detection/pipes/observable_pipe.ts b/modules/angular2/src/change_detection/pipes/observable_pipe.ts index 3d871f7fdc..2e775ed6a1 100644 --- a/modules/angular2/src/change_detection/pipes/observable_pipe.ts +++ b/modules/angular2/src/change_detection/pipes/observable_pipe.ts @@ -30,22 +30,13 @@ import {ChangeDetectorRef} from '../change_detector_ref'; * @exportedAs angular2/pipes */ export class ObservablePipe extends Pipe { - _ref: ChangeDetectorRef; + _latestValue: Object = null; + _latestReturnedValue: Object = null; - _latestValue: Object; - _latestReturnedValue: Object; + _subscription: Object = null; + _observable: Observable = null; - _subscription: Object; - _observable: Observable; - - constructor(ref: ChangeDetectorRef) { - super(); - this._ref = ref; - this._latestValue = null; - this._latestReturnedValue = null; - this._subscription = null; - this._observable = null; - } + constructor(public _ref: ChangeDetectorRef) { super(); } supports(obs): boolean { return ObservableWrapper.isObservable(obs); } @@ -106,4 +97,4 @@ export class ObservablePipeFactory extends PipeFactory { supports(obs): boolean { return ObservableWrapper.isObservable(obs); } create(cdRef): Pipe { return new ObservablePipe(cdRef); } -} \ No newline at end of file +} diff --git a/modules/angular2/src/change_detection/pipes/promise_pipe.ts b/modules/angular2/src/change_detection/pipes/promise_pipe.ts index 5048f7c7a6..95b0956f3c 100644 --- a/modules/angular2/src/change_detection/pipes/promise_pipe.ts +++ b/modules/angular2/src/change_detection/pipes/promise_pipe.ts @@ -29,17 +29,11 @@ import {ChangeDetectorRef} from '../change_detector_ref'; * @exportedAs angular2/pipes */ export class PromisePipe extends Pipe { - _ref: ChangeDetectorRef; - _latestValue: Object; - _latestReturnedValue: Object; + _latestValue: Object = null; + _latestReturnedValue: Object = null; _sourcePromise: Promise; - constructor(ref: ChangeDetectorRef) { - super(); - this._ref = ref; - this._latestValue = null; - this._latestReturnedValue = null; - } + constructor(public _ref: ChangeDetectorRef) { super(); } supports(promise): boolean { return isPromise(promise); } diff --git a/modules/angular2/src/change_detection/pipes/uppercase_pipe.ts b/modules/angular2/src/change_detection/pipes/uppercase_pipe.ts index 63b99365a5..58b193a4b2 100644 --- a/modules/angular2/src/change_detection/pipes/uppercase_pipe.ts +++ b/modules/angular2/src/change_detection/pipes/uppercase_pipe.ts @@ -24,11 +24,8 @@ import {Pipe} from './pipe'; * @exportedAs angular2/pipes */ export class UpperCasePipe extends Pipe { - _latestValue: string; - constructor() { - super(); - this._latestValue = null; - } + _latestValue: string = null; + supports(str): boolean { return isString(str); } onDestroy(): void { this._latestValue = null; } diff --git a/modules/angular2/src/change_detection/pregen_proto_change_detector.ts b/modules/angular2/src/change_detection/pregen_proto_change_detector.ts index c61d5392ad..e0020733c8 100644 --- a/modules/angular2/src/change_detection/pregen_proto_change_detector.ts +++ b/modules/angular2/src/change_detection/pregen_proto_change_detector.ts @@ -6,8 +6,6 @@ import {coalesce} from './coalesce'; export {Function as PregenProtoChangeDetectorFactory}; export class PregenProtoChangeDetector extends ProtoChangeDetector { - constructor() { super(); } - static isSupported(): boolean { return false; } instantiate(dispatcher: any): ChangeDetector {