Last active
December 10, 2021 07:03
-
-
Save obaranovskyi/d6244dff07d6f394ab4be351c91c8ed3 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, firstValueFrom, Observable, Subject } from 'rxjs'; | |
async function demo<T>(observable: Observable<T>): Promise<void> { | |
try { | |
const result = await firstValueFrom(observable); | |
console.log(result); | |
} 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