Skip to content

[SO] Why RxJS startWIth does not emit when used with lastValueFrom? #7329

Answered by demensky
vajahath asked this question in Q&A
Discussion options

You must be logged in to vote

lastValueFrom:

Converts an observable to a promise by subscribing to the observable, waiting for it to complete

In your case "complete" never happens.

Here is an example where console.log will be executed:

const sub = new Subject();
const obs = sub.asObservable().pipe(startWith('startWith'));
lastValueFrom(obs).then(console.log);

sub.complete();

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by vajahath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants