Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: apply nullable checks for async inputs (#74)
- Loading branch information
1 parent
66ed9b9
commit 4b9dc22
Showing
7 changed files
with
54 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { Observable, of } from 'rxjs'; | ||
import { delay } from 'rxjs/operators'; | ||
|
||
@Pipe({ | ||
name: 'valueToAsyncValue', | ||
}) | ||
export class ValueToAsyncValuePipe implements PipeTransform { | ||
transform(value: string): Observable<string> { | ||
return of(value).pipe(delay(10)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Observable } from 'rxjs'; | ||
import { filter } from 'rxjs/operators'; | ||
|
||
export function isNotNullable<T>(it: T): it is NonNullable<T> { | ||
return it !== null && it !== undefined; | ||
} | ||
|
||
export const filterNullable = <T>() => (source: Observable<T>) => | ||
source.pipe(filter(isNotNullable)); |