Created
December 10, 2021 08:54
-
-
Save obaranovskyi/819b16907d3e374241a2dc01bac0e10b 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, { defaultValue: 25 }); | |
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