diff --git a/modules/angular2/change_detection.ts b/modules/angular2/change_detection.ts index e3c0c349d6..bb06ca84a3 100644 --- a/modules/angular2/change_detection.ts +++ b/modules/angular2/change_detection.ts @@ -21,11 +21,11 @@ export { WrappedValue, PipeTransform, + PipeOnDestroy, IterableDiffers, IterableDiffer, IterableDifferFactory, KeyValueDiffers, KeyValueDiffer, - KeyValueDifferFactory, - BasePipeTransform + KeyValueDifferFactory } from 'angular2/src/change_detection/change_detection'; diff --git a/modules/angular2/src/change_detection/change_detection.ts b/modules/angular2/src/change_detection/change_detection.ts index c3fc2846d0..99d5110618 100644 --- a/modules/angular2/src/change_detection/change_detection.ts +++ b/modules/angular2/src/change_detection/change_detection.ts @@ -44,7 +44,7 @@ export {DynamicChangeDetector} from './dynamic_change_detector'; export {ChangeDetectorRef} from './change_detector_ref'; export {IterableDiffers, IterableDiffer, IterableDifferFactory} from './differs/iterable_differs'; export {KeyValueDiffers, KeyValueDiffer, KeyValueDifferFactory} from './differs/keyvalue_differs'; -export {PipeTransform, PipeOnDestroy, BasePipeTransform} from './pipe_transform'; +export {PipeTransform, PipeOnDestroy} from './pipe_transform'; export {WrappedValue} from './change_detection_util'; /** diff --git a/modules/angular2/src/change_detection/pipe_lifecycle_reflector.dart b/modules/angular2/src/change_detection/pipe_lifecycle_reflector.dart index 59ae1619e4..9fb8545f71 100644 --- a/modules/angular2/src/change_detection/pipe_lifecycle_reflector.dart +++ b/modules/angular2/src/change_detection/pipe_lifecycle_reflector.dart @@ -2,4 +2,4 @@ library angular2.core.compiler.pipe_lifecycle_reflector; import 'package:angular2/src/change_detection/pipe_transform.dart'; -bool implementsOnDestroy(Object pipe) => pipe is PipeOnDestroy; \ No newline at end of file +bool implementsOnDestroy(Object pipe) => pipe is PipeOnDestroy; diff --git a/modules/angular2/src/change_detection/pipe_lifecycle_reflector.ts b/modules/angular2/src/change_detection/pipe_lifecycle_reflector.ts index e0728348ce..6f6863cd3b 100644 --- a/modules/angular2/src/change_detection/pipe_lifecycle_reflector.ts +++ b/modules/angular2/src/change_detection/pipe_lifecycle_reflector.ts @@ -1,3 +1,3 @@ export function implementsOnDestroy(pipe: any): boolean { return pipe.constructor.prototype.onDestroy; -} \ No newline at end of file +} diff --git a/modules/angular2/src/change_detection/pipe_transform.ts b/modules/angular2/src/change_detection/pipe_transform.ts index eeed58e581..557a3cbf2d 100644 --- a/modules/angular2/src/change_detection/pipe_transform.ts +++ b/modules/angular2/src/change_detection/pipe_transform.ts @@ -37,26 +37,3 @@ export interface PipeTransform { transform(value: any, args: List): any; } * ``` */ export interface PipeOnDestroy { onDestroy(): void; } - -/** - * Provides default implementation of the `onDestroy` method. - * - * #Example - * - * ``` - * class DoublePipe extends BasePipe { - * transform(value) { - * return `${value}${value}`; - * } - * } - * ``` - */ -@CONST() -export class BasePipeTransform implements PipeTransform, PipeOnDestroy { - onDestroy(): void {} - transform(value: any, args: List): any { return _abstract(); } -} - -function _abstract() { - throw new BaseException('This method is abstract'); -} diff --git a/modules/angular2/src/pipes/async_pipe.ts b/modules/angular2/src/pipes/async_pipe.ts index 58d43a2d12..6280261373 100644 --- a/modules/angular2/src/pipes/async_pipe.ts +++ b/modules/angular2/src/pipes/async_pipe.ts @@ -2,7 +2,7 @@ import {isBlank, isPresent, isPromise, CONST, BaseException} from 'angular2/src/ import {Observable, Promise, ObservableWrapper} from 'angular2/src/facade/async'; import {Injectable} from 'angular2/di'; -import {PipeTransform, WrappedValue} from 'angular2/change_detection'; +import {PipeTransform, PipeOnDestroy, WrappedValue} from 'angular2/change_detection'; import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception'; import {ChangeDetectorRef} from 'angular2/change_detection'; @@ -59,7 +59,7 @@ var _observableStrategy = new ObservableStrategy(); */ @Pipe({name: 'async'}) @Injectable() -export class AsyncPipe implements PipeTransform { +export class AsyncPipe implements PipeTransform, PipeOnDestroy { _latestValue: Object = null; _latestReturnedValue: Object = null; diff --git a/modules/angular2/src/pipes/date_pipe.ts b/modules/angular2/src/pipes/date_pipe.ts index 78867a0d05..bb91ea2d12 100644 --- a/modules/angular2/src/pipes/date_pipe.ts +++ b/modules/angular2/src/pipes/date_pipe.ts @@ -12,7 +12,7 @@ import {DateFormatter} from 'angular2/src/facade/intl'; import {Injectable} from 'angular2/di'; import {StringMapWrapper, ListWrapper} from 'angular2/src/facade/collection'; -import {PipeTransform, WrappedValue, BasePipeTransform} from 'angular2/change_detection'; +import {PipeTransform, WrappedValue} from 'angular2/change_detection'; import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception'; import {Pipe} from 'angular2/src/core/annotations/decorators'; @@ -77,7 +77,7 @@ var defaultLocale: string = 'en-US'; @CONST() @Pipe({name: 'date'}) @Injectable() -export class DatePipe extends BasePipeTransform { +export class DatePipe implements PipeTransform { static _ALIASES = { 'medium': 'yMMMdjms', 'short': 'yMdjm', diff --git a/modules/angular2/src/pipes/json_pipe.ts b/modules/angular2/src/pipes/json_pipe.ts index a088d95c69..3357b7734b 100644 --- a/modules/angular2/src/pipes/json_pipe.ts +++ b/modules/angular2/src/pipes/json_pipe.ts @@ -1,7 +1,7 @@ import {isBlank, isPresent, Json, CONST} from 'angular2/src/facade/lang'; import {Injectable} from 'angular2/di'; -import {PipeTransform, WrappedValue, BasePipeTransform} from 'angular2/change_detection'; +import {PipeTransform, WrappedValue} from 'angular2/change_detection'; import {Pipe} from 'angular2/src/core/annotations/decorators'; @@ -31,6 +31,6 @@ import {Pipe} from 'angular2/src/core/annotations/decorators'; @CONST() @Pipe({name: 'json'}) @Injectable() -export class JsonPipe extends BasePipeTransform { +export class JsonPipe implements PipeTransform { transform(value: any, args: List = null): string { return Json.stringify(value); } } diff --git a/modules/angular2/src/pipes/limit_to_pipe.ts b/modules/angular2/src/pipes/limit_to_pipe.ts index 95ee2e4a16..721e0bbaed 100644 --- a/modules/angular2/src/pipes/limit_to_pipe.ts +++ b/modules/angular2/src/pipes/limit_to_pipe.ts @@ -10,7 +10,7 @@ import {ListWrapper} from 'angular2/src/facade/collection'; import {Math} from 'angular2/src/facade/math'; import {Injectable} from 'angular2/di'; -import {PipeTransform, WrappedValue, BasePipeTransform} from 'angular2/change_detection'; +import {PipeTransform, WrappedValue} from 'angular2/change_detection'; import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception'; import {Pipe} from 'angular2/src/core/annotations/decorators'; @@ -78,6 +78,4 @@ export class LimitToPipe implements PipeTransform { } return ListWrapper.slice(value, left, right); } - - onDestroy(): void {} } diff --git a/modules/angular2/src/pipes/lowercase_pipe.ts b/modules/angular2/src/pipes/lowercase_pipe.ts index 146d71f03c..afd07656c1 100644 --- a/modules/angular2/src/pipes/lowercase_pipe.ts +++ b/modules/angular2/src/pipes/lowercase_pipe.ts @@ -1,7 +1,7 @@ import {isString, StringWrapper, CONST, isBlank} from 'angular2/src/facade/lang'; import {Injectable} from 'angular2/di'; -import {PipeTransform, WrappedValue, BasePipeTransform} from 'angular2/change_detection'; +import {PipeTransform, WrappedValue} from 'angular2/change_detection'; import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception'; @@ -30,7 +30,7 @@ import {Pipe} from 'angular2/src/core/annotations/decorators'; @CONST() @Pipe({name: 'lowercase'}) @Injectable() -export class LowerCasePipe extends BasePipeTransform { +export class LowerCasePipe implements PipeTransform { transform(value: string, args: List = null): string { if (isBlank(value)) return value; if (!isString(value)) { diff --git a/modules/angular2/src/pipes/number_pipe.ts b/modules/angular2/src/pipes/number_pipe.ts index d7048fe8f9..f0c2424445 100644 --- a/modules/angular2/src/pipes/number_pipe.ts +++ b/modules/angular2/src/pipes/number_pipe.ts @@ -13,7 +13,7 @@ import {NumberFormatter, NumberFormatStyle} from 'angular2/src/facade/intl'; import {Injectable} from 'angular2/di'; import {ListWrapper} from 'angular2/src/facade/collection'; -import {PipeTransform, WrappedValue, BasePipeTransform} from 'angular2/change_detection'; +import {PipeTransform, WrappedValue} from 'angular2/change_detection'; import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception'; import {Pipe} from 'angular2/src/core/annotations/decorators'; @@ -23,7 +23,7 @@ var _re = RegExpWrapper.create('^(\\d+)?\\.((\\d+)(\\-(\\d+))?)?$'); @CONST() @Injectable() -export class NumberPipe extends BasePipeTransform { +export class NumberPipe { static _format(value: number, style: NumberFormatStyle, digits: string, currency: string = null, currencyAsSymbol: boolean = false): string { if (isBlank(value)) return null; @@ -84,7 +84,7 @@ export class NumberPipe extends BasePipeTransform { @CONST() @Pipe({name: 'number'}) @Injectable() -export class DecimalPipe extends NumberPipe { +export class DecimalPipe extends NumberPipe implements PipeTransform { transform(value: any, args: any[]): string { var digits: string = ListWrapper.first(args); return NumberPipe._format(value, NumberFormatStyle.DECIMAL, digits); @@ -103,7 +103,7 @@ export class DecimalPipe extends NumberPipe { @CONST() @Pipe({name: 'percent'}) @Injectable() -export class PercentPipe extends NumberPipe { +export class PercentPipe extends NumberPipe implements PipeTransform { transform(value: any, args: any[]): string { var digits: string = ListWrapper.first(args); return NumberPipe._format(value, NumberFormatStyle.PERCENT, digits); @@ -126,7 +126,7 @@ export class PercentPipe extends NumberPipe { @CONST() @Pipe({name: 'currency'}) @Injectable() -export class CurrencyPipe extends NumberPipe { +export class CurrencyPipe extends NumberPipe implements PipeTransform { transform(value: any, args: any[]): string { var currencyCode: string = isPresent(args) && args.length > 0 ? args[0] : 'USD'; var symbolDisplay: boolean = isPresent(args) && args.length > 1 ? args[1] : false; diff --git a/modules/angular2/src/pipes/uppercase_pipe.ts b/modules/angular2/src/pipes/uppercase_pipe.ts index a76768a650..9227c85944 100644 --- a/modules/angular2/src/pipes/uppercase_pipe.ts +++ b/modules/angular2/src/pipes/uppercase_pipe.ts @@ -1,7 +1,7 @@ import {isString, StringWrapper, CONST, isBlank} from 'angular2/src/facade/lang'; import {Injectable} from 'angular2/di'; -import {PipeTransform, WrappedValue, BasePipeTransform} from 'angular2/change_detection'; +import {PipeTransform, WrappedValue} from 'angular2/change_detection'; import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception'; import {Pipe} from 'angular2/src/core/annotations/decorators'; @@ -29,7 +29,7 @@ import {Pipe} from 'angular2/src/core/annotations/decorators'; @CONST() @Pipe({name: 'uppercase'}) @Injectable() -export class UpperCasePipe extends BasePipeTransform { +export class UpperCasePipe implements PipeTransform { transform(value: string, args: List = null): string { if (isBlank(value)) return value; if (!isString(value)) { diff --git a/modules/angular2/test/pipes/json_pipe_spec.ts b/modules/angular2/test/pipes/json_pipe_spec.ts index 59bb82fa16..386a2ddf70 100644 --- a/modules/angular2/test/pipes/json_pipe_spec.ts +++ b/modules/angular2/test/pipes/json_pipe_spec.ts @@ -73,11 +73,5 @@ export function main() { }); }); - - describe("onDestroy", () => { - it("should do nothing when no latest value", - () => { expect(() => pipe.onDestroy()).not.toThrow(); }); - }); - }); }