Skip to content

Instantly share code, notes, and snippets.

@obaranovskyi
Created December 10, 2021 07:26
Show Gist options
  • Save obaranovskyi/b0879ab5a1ff34cce9e1a346d589ed65 to your computer and use it in GitHub Desktop.
Save obaranovskyi/b0879ab5a1ff34cce9e1a346d589ed65 to your computer and use it in GitHub Desktop.
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