1
1
import { PipeFactory } from 'angular2/src/change_detection/pipes/pipe' ;
2
2
import { async } from 'angular2/src/change_detection/change_detection' ;
3
- import { Pipe , PipeRegistry , defaultPipes } from 'angular2/change_detection' ;
3
+ import { NullPipeFactory , Pipe , PipeRegistry , defaultPipes } from 'angular2/change_detection' ;
4
4
import { bind } from 'angular2/di' ;
5
5
import { ObservablePipe } from 'angular2/pipes' ;
6
6
import * as Rx from 'rx' ;
@@ -21,21 +21,40 @@ export class RxPipe extends ObservablePipe {
21
21
e => { throw e ; }
22
22
) ;
23
23
}
24
-
25
24
}
26
25
27
26
export class RxPipeFactory extends PipeFactory {
28
27
constructor ( ) { super ( ) ; }
29
-
30
28
supports ( obs ) { return isObservable ( obs ) ; }
31
-
32
29
create ( cdRef ) : Pipe { return new RxPipe ( cdRef ) ; }
33
30
}
34
31
35
32
export var rxAsync = [ new RxPipeFactory ( ) ] . concat ( async ) ;
36
33
34
+ export class GetPipe extends Pipe {
35
+ onDestroy ( ) { }
36
+ supports ( val ) { return true }
37
+ transform ( val ) {
38
+ // console.log('wat1', val)
39
+ return function ( prop ) {
40
+ // console.log('wat2', val, prop);
41
+ return ( val ) ? val [ prop ] : val ;
42
+ }
43
+ }
44
+ }
45
+
46
+ export class GetPipeFactory extends PipeFactory {
47
+ constructor ( ) { super ( ) ; }
48
+ supports ( val ) { return true }
49
+ create ( ref : any ) : Pipe { return new GetPipe ( ) ; }
50
+ }
51
+
52
+ export var get = [ new GetPipeFactory ( ) , new NullPipeFactory ( ) ] ;
53
+
54
+
37
55
export var rxPipes = Object . assign ( { } , defaultPipes , {
38
- 'async' : rxAsync
56
+ 'async' : rxAsync ,
57
+ 'get' : get
39
58
} ) ;
40
59
41
60
export var rxPipeRegistry = [
0 commit comments