Created
December 10, 2021 08:46
-
-
Save obaranovskyi/8ab32a30f23ecd171583f1ee6e84daa2 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 { lastValueFrom, Observable, Subject } from 'rxjs'; | |
async function demo<T>(observable: Observable<T>): Promise<void> { | |
const result = await lastValueFrom(observable); | |
console.log(result); | |
} | |
const subject = new Subject(); | |
demo(subject.asObservable()); | |
subject.next(1); | |
subject.next(2); | |
subject.next(3); | |
subject.next(4); | |
subject.next(5); | |
subject.complete(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment