In Angular HTTP client, yes, they are. This is why:
observer.next(new HttpResponse({
body,
headers,
status,
statusText,
url: url || undefined,
}));
// The full body has been received and delivered, no further events
// are possible. This request is complete.
observer.complete();
After observer.next(...)
, observer.complete()
gets called synchronously. Since this a synchronous call, there is no difference in using lastValueFrom
or firstValueFrom
.
The only difference here is that firstValueFrom
will resolve the Promise once next(...)
gets called, while lastValueFrom
will resolve the Promise once complete()
gets called. Since next
and complete
get called synchronously, one after another, there is really no much difference here.
However, one thing to note here is: if you're using reportProgress = true
, you will want to use lastValueFrom
since you'd like to catch the last value emitted from the producer - that is, either the response or the error. You don't want to resolve the Promise with the progress status update. If you do, then you don't want to use Promises at all.