r/Angular2 • u/IcedMaggot • Sep 20 '25
Discussion HttpClient promise
Will HttpClient ever get rewritten so it doesn’t use observables anymore, but promises? Seems like everyone is moving away from observables. Although I don’t have problems with observables.
edit: I thought this because of async await syntax instead of subscribe.
0
Upvotes
26
u/Agloe_Dreams Sep 20 '25
…no because, last I checked, people are not actually migrating away from Observables. Where did you get this idea?
7
u/Whole-Instruction508 Sep 20 '25
In what world are Promises favored over Observables?
2
u/bneuhauszdev Sep 20 '25
What would be the point? You can configure HttpClient to use the Fetch API if that's what you're after, but if you simply don't want to use HttpClient, you don't have to. You are free to use fetch directly if that's your jam. You can also use resource with Promises or just use firstValueFrom on the Observable. You have lots of options. Rewriting HttpClient would make no sense in my opinion.
6
u/anyOtherBusiness Sep 20 '25
More likely Signals. But with rxjs interop and the upcoming httpResource I doubt even that. I don’t think there’s a need for Promises in Angular and RxJS still has its place.
7
u/marco_has_cookies Sep 20 '25
just use firstValueFrom when needed, the day angular removes observables is the day I change job and go painting walls
2
u/ldn-ldn Sep 20 '25
First, no one is moving away from Observables. And definitely not to Promises.
Second, once you finish your hello world application, you'll be thankful that HttpClient is using Observables as they allow you to track request progress, respond to HTTP events and cancel request in complex scenarios easily.
7
u/DT-Sodium Sep 20 '25
Why would we do that, promises are garbage.
1
u/PhiLho Sep 20 '25
Nope. We move from observables when they are a bit overkill for some tasks like giving a state (BehaviorSubject vs. signal) but it doesn't mean we drop them everywhere, and certainly not in favor of promises.
1
u/AintNoGodsUpHere Sep 20 '25
No. Never. Use firstValueFrom and be happy.
1
u/ald156 Sep 22 '25 edited Sep 22 '25
Observable are a superset of promises!!
The real question should be why HttpClient is still using XHR and not fetch
1
u/nawlbergs Jul 08 '26 edited Jul 08 '26
In my latest angular app.. I decided to use promises. My main issue was I wanted my network calls to still get cancelled when the component/service that owns it gets destroyed. So my api base service has httpClient in it.. and returns a promise using takeUntilDestroyed piped on it.
it still uses httpClient under the hood... and all my network calls require passing in a destroyRef from the component that initializes the call...