Created
December 10, 2021 08:51
-
-
Save obaranovskyi/739d310eb14e8026b93a7bf329561a95 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
import { EmptyError, lastValueFrom, Observable, Subject } from 'rxjs'; | |
async function demo<T>(observable: Observable<T>): Promise<void> { | |
try { | |
const promiseResult = await lastValueFrom(observable); | |
console.log(promiseResult); | |
} catch (error) { | |
console.log(error instanceof EmptyError); | |
console.error(error); | |
} | |
} | |
const subject = new Subject(); | |
demo(subject.asObservable()); | |
subject.complete(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment