feat(pipes): add support for pure pipes
By default, pipes are pure. This means that an instance of a pipe will be reused and the pipe will be called only when its arguments change. BREAKING CHANGE Before: @Pipe({name: 'date'}) class DatePipe {} defines an impure pipe. After: @Pipe({name: 'date'}) class DatePipe {} defines a pure pipe. @Pipe({name: 'date', pure: false}) class DatePipe {} defines an impure pipe. Closes #3966
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import {CONST, CONST_EXPR} from 'angular2/src/core/facade/lang';
|
||||
import {ChangeDetectionStrategy} from 'angular2/src/core/change_detection';
|
||||
import {isPresent, CONST, CONST_EXPR} from 'angular2/src/core/facade/lang';
|
||||
import {InjectableMetadata} from 'angular2/src/core/di/metadata';
|
||||
import {ChangeDetectionStrategy} from 'angular2/src/core/change_detection';
|
||||
|
||||
/**
|
||||
* Directives allow you to attach behavior to elements in the DOM.
|
||||
@ -861,11 +861,15 @@ export class ComponentMetadata extends DirectiveMetadata {
|
||||
@CONST()
|
||||
export class PipeMetadata extends InjectableMetadata {
|
||||
name: string;
|
||||
_pure: boolean;
|
||||
|
||||
constructor({name}: {name: string}) {
|
||||
constructor({name, pure}: {name: string, pure: boolean}) {
|
||||
super();
|
||||
this.name = name;
|
||||
this._pure = pure;
|
||||
}
|
||||
|
||||
get pure(): boolean { return isPresent(this._pure) ? this._pure : true; }
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user