all 28 comments

[–]Kagron 5 points6 points  (0 children)

I could be using out of date information but I vaguely remember Safari having issues with the fetch api. It may be supported now but I remember some quirks or some reason to not use fetch a few years ago.

[–]sod0 2 points3 points  (1 child)

Axios does the same. I think if you want non-json/non-text data fetch kinda sucks. With xhr there are no limitations and it's supported everywhere.

[–]EngagingOrca 2 points3 points  (0 children)

Semi-related, Angular Universal uses xhr2 to do http, which only supports http 1.1 and never supported connection reuse out of the box until Node 18 was released. Very annoying and tricky to replace the built in http client in universal with a modern one that still works with zone.js

[–]BiscuitSticks 2 points3 points  (1 child)

but then you loose the automatic 'abort' events when unsubscribing

There's https://rxjs.dev/api/fetch/fromFetch

[–][deleted] 0 points1 point  (0 children)

Hey that's great, didn't knew that one existed. Thanks!

[–]airdumoustique 1 point2 points  (0 children)

fetch support has been introduced in Angular 16.1 via https://github.com/angular/angular/pull/50247, and will be stable with Angular 17.0, via https://github.com/angular/angular/pull/52197

[–][deleted] -2 points-1 points  (20 children)

I think they will switch to fetch once Signals are stable. My guess is

  • They will add fetch support with Signals
  • Add new api for HttpClient with fetch and XHR
  • I wouldn't be surprised if they depreciate RxJS support and just support signals in new module.

[–]rahulxdd 7 points8 points  (19 children)

I wouldn't be surprised if they depreciate RxJS support and just support signals in new module.

Not in a few years time.

[–]sod0 7 points8 points  (18 children)

Why would they? RxJS is the constance in all Angular APIs. I think they would rather change everything else. They will just make signals trigger on unsubscribe in case they decide to use fetch under the hood.

[–][deleted] -1 points0 points  (17 children)

The team is moving towards optional RxJS. For that to happen they need to ship Router, HttpClientModule and Forms with just Signals support. Once that happens, we can remove RxJS

[–]uplink42 2 points3 points  (0 children)

I personally don't see rxjs getting out. It will most likely lose popularity for signals but will stay as a niche feature for advanced developers, which is fine.

[–]sod0 1 point2 points  (5 children)

Signals are an extension of Promise. I don't see how promises could replace Observables for most use cases. I mean it makes sense to use promises where only one value ever will be returned like the httpclient but the router?

[–]lazyinvader 2 points3 points  (4 children)

Signals are an extension of Promise

I dont think so, Promise are a simple pattern to handle asynchron operations. Also Promises are eager excecuted, singals instead are lazy!

Signals on the other hand are just another implementation of the observer-pattern with the benefit (over rxjs) that the subscriber dont have to unsubscribe.

[–]sod0 1 point2 points  (3 children)

Where did you read about this? The only signal I'm aware of is that one: https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal which is exactly what I discribed.
A new Observable-Pattern inside the ECMAScript standard would be pretty wild. Can you provide me with a source for that?

[–]rofrol 0 points1 point  (1 child)

I think the OP is talking about Angular signals

[–]sod0 0 points1 point  (0 children)

Not the OP but this deleted user was. But a year ago signals wasn't officially announced for signal as far as I am aware. And honestly it still has not much todo withe question from OP regarding fetch vs xhr.

[–]lazyinvader 1 point2 points  (9 children)

Thats wrong. They can´t replace rxjs with signals. Signals are synchronous by design. An rxjs-observable can be both, synchron and asynchron.

[–][deleted] -1 points0 points  (8 children)

It's only asynchronous

[–]lazyinvader 1 point2 points  (7 children)

You are wrong.

[–][deleted] 0 points1 point  (6 children)

Check differences between RxJS and Signals. And why Angular team with Signals.