Last active
January 27, 2019 19:00
-
-
Save imkrish/9d1822cdf1088f40ab096d5b9b2132d4 to your computer and use it in GitHub Desktop.
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
const observable = of('response') | |
function hasValue(value: any) { | |
return value !== null && value !== undefined; | |
} | |
function getValue<T>(observable: Observable<T>): Promise<T> { | |
return observable | |
.pipe( | |
filter(hasValue), | |
first() | |
) | |
.toPromise(); | |
} | |
const result = await getValue(observable) | |
// Do the logic with the result | |
// ................. | |
// ................. | |
// ................. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment