Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

Commit b346a36

Browse files
committed
feat(pipes): include GetPipe
1 parent d7eaee0 commit b346a36

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/common/rxPipes.ts

+24-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {PipeFactory} from 'angular2/src/change_detection/pipes/pipe';
22
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';
44
import {bind} from 'angular2/di';
55
import {ObservablePipe} from 'angular2/pipes';
66
import * as Rx from 'rx';
@@ -21,21 +21,40 @@ export class RxPipe extends ObservablePipe {
2121
e => { throw e; }
2222
);
2323
}
24-
2524
}
2625

2726
export class RxPipeFactory extends PipeFactory {
2827
constructor() { super(); }
29-
3028
supports(obs) { return isObservable(obs); }
31-
3229
create(cdRef): Pipe { return new RxPipe(cdRef); }
3330
}
3431

3532
export var rxAsync = [ new RxPipeFactory() ].concat(async);
3633

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+
3755
export var rxPipes = Object.assign({}, defaultPipes, {
38-
'async': rxAsync
56+
'async': rxAsync,
57+
'get': get
3958
});
4059

4160
export var rxPipeRegistry = [

0 commit comments

Comments
 (0)