Skip to content

Commit

Permalink
Add custom rxjs operator filterUndefined
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalastax committed Oct 25, 2016
1 parent 248c77b commit bf64834
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/rx-custom/add/filterUndefined.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Observable } from "rxjs"
import { filterUndefined } from "../operator/filterUndefined"

declare module "rxjs/Observable" {
interface Observable<T> {
filterUndefined: typeof filterUndefined;
}
}

Observable.prototype.filterUndefined = filterUndefined
5 changes: 5 additions & 0 deletions src/rx-custom/operator/filterUndefined.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Observable } from "rxjs"

export function filterUndefined<T>(this: Observable<T | undefined>): Observable<T> {
return this.filter(x => typeof x !== "undefined")
}
2 changes: 2 additions & 0 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ import "rxjs/add/operator/delay"
import "rxjs/add/operator/catch"
import "rxjs/add/observable/of"

import "rx-custom/add/filterUndefined"

// const isDev = (process && process.env && process.env.NODE_ENV) !== "production"

0 comments on commit bf64834

Please sign in to comment.