Created
December 10, 2021 07:26
-
-
Save obaranovskyi/b0879ab5a1ff34cce9e1a346d589ed65 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 { firstValueFrom, Observable, Subject } from 'rxjs'; | |
async function demo<T>(observable: Observable<T>): Promise<void> { | |
try { | |
const result = await firstValueFrom(observable, { defaultValue: 25 }); | |
console.log(result); | |
} catch (error) { | |
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