Skip to content

Instantly share code, notes, and snippets.

@imkrish
Last active January 27, 2019 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imkrish/9d1822cdf1088f40ab096d5b9b2132d4 to your computer and use it in GitHub Desktop.
Save imkrish/9d1822cdf1088f40ab096d5b9b2132d4 to your computer and use it in GitHub Desktop.
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