feat(ivy): add canonical example of a pipe. (#21834)

PR Close #21834
This commit is contained in:
Misko Hevery
2018-01-27 13:07:03 -08:00
committed by Alex Rickabaugh
parent f816666ede
commit 743d8bc845
6 changed files with 243 additions and 5 deletions

View File

@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {PipeTransform} from '../../change_detection/pipe_transform';
import {RendererType2} from '../../render/api';
import {Type} from '../../type';
import {resolveRendererType2} from '../../view/util';
@ -23,6 +24,8 @@ export interface DirectiveType<T> extends Type<T> { ngDirectiveDef: DirectiveDef
export const enum DirectiveDefFlags {ContentQuery = 0b10}
export interface PipeType<T> extends Type<T> { ngPipeDef: PipeDef<T>; }
/**
* `DirectiveDef` is a compiled version of the Directive used by the renderer instructions.
*/
@ -109,6 +112,31 @@ export interface ComponentDef<T> extends DirectiveDef<T> {
readonly rendererType: RendererType2|null;
}
/**
*
*/
export interface PipeDef<T> {
/**
* factory function used to create a new directive instance.
*
* NOTE: this property is short (1 char) because it is used in
* component templates which is sensitive to size.
*/
n: () => PipeTransform;
/**
* Whether or not the pipe is pure.
*
* Pure pipes result only depends on the pipe input and not on internal
* state of the pipe.
*/
pure: boolean;
/* The following are lifecycle hooks for this pipe */
onDestroy: (() => void)|null;
}
export interface DirectiveDefArgs<T> {
type: Type<T>;
factory: () => T | [T];