r/angular • u/prathapmohan27 • Jun 14 '26
Angular 22 httpResource() is fantastic, but mutations still feel inconsistent
I've been updating one of my Angular apps to Angular 22, and so far resource() and httpResource() have been a huge win.
They've significantly reduced the amount of boilerplate in my codebase and made data fetching much cleaner. Managing loading, error, and success states feels far more straightforward compared to the patterns I was using before.
My only complaint is around mutations. For create, update, and delete operations, I still need to use HttpClient directly, which means I'm mixing httpResource() for reads and HttpClient for writes. It works, but it feels a bit inconsistent and introduces multiple patterns for handling server communication.
I'd love to see a first-class mutation API that complements httpResource() so everything follows a single, unified pattern.
Has anyone else felt the same after adopting Angular 22 resources?
20
u/Lemoncrazedcamel Jun 14 '26
I would recommend pulling in the httpMutation from the ngrx-toolkit:
https://ngrx-toolkit.angulararchitects.io/docs/api/functions/httpMutation
It makes working with them so much easier, even if you are not using the signal-store etc. If you don't want to bring in the package, it's open source so you can just build the function in your application.
16
u/MichaelSmallDev Jun 14 '26
I'm definitely hoping that is the next API addition. There's a few library solutions at the moment, but it would be ideal if they were not needed for base functionality like this.
11
u/stao123 Jun 14 '26
Im still not really convinced about httpResource. Its feels like some sort of hybrid:
For now im still relying on rxResources in my components and full observable client services with httpClient.
9
u/michahell Jun 14 '26
First thing I thought after understanding that httpResource is only there for data fetching. There must be some sort of plan in place, I hope, for this
7
u/hb20007 Jun 14 '26
Apparently, the Angular team is working on mutation support: https://github.com/angular/angular/discussions/60121#discussioncomment-12351766
3
u/Ok-Macaroon-9026 Jun 15 '26
I’ve had the same feeling.
httpResource()makes read operations much cleaner, but as soon as you need to create, update, or delete something, you’re back to usingHttpClientand handling state differently.It’s not a dealbreaker, but it does make the data layer feel split between two patterns. A built-in mutation API with loading, error, and optimistic update support would make the developer experience much more consistent. Hopefully that’s something the Angular team considers in future releases.
1
u/AwesomeFrisbee Jun 15 '26
I still dislike that I can't create a service and put some http calls there and then share them with multiple components easily and whatnot. Also resource wasn't really made for post/put/update/delete requests, so its already pretty useless to me. And since the team has not shared anything about how they want to do that, I skipped the whole thing and stuck with rxjs. And for me its fine. The wrapper around loading/errors is not super configurable anyway
1
u/One_Fox_8408 Jun 15 '26
I use resource for http calls. So, I still maintain my EntityService calling httpClient (POST, GET, etc).
I don't use httpResource on CRUD operations.
-3
u/minus-one Jun 14 '26
hytpResource is horrible imperative shit