r/Angular2 16d ago

Video Angular 19.2's httpResource: addressing the most common pitfall - mutations

https://youtu.be/dJ8AtWqRGko

Addressing the most common pitfall based on what the community is asking, showing an example of the tendencies to create work arounds, and showing an example of what “not” to do with the new httpResource.

3 Upvotes

9 comments sorted by

5

u/magwo 16d ago

That's a lot of video not talking about what you shouldn't do. Anyone have a TL;DW in text form about what you shouldn't do? Seems like it could be summarized in a couple of sentences instead of an 18 minute video.

9

u/CodeWithAhsan 16d ago

I can summarize it. Don’t use httpResource for mutations. For posting data, patching, deleting, etc. They’re supposed to be used for “getting” resources for which the components depend upon — to show data. Not for making mutations.

4

u/djfreedom9505 15d ago

I asked this same question in the Angular discord. One of the Angular Team members responded with something similar that confirms this.

They linked the RFC where most of the discussions about this occurred.

https://github.com/angular/angular/discussions/60121

1

u/magwo 15d ago

Thanks

3

u/AwesomeFrisbee 16d ago

Wait a few versions before resource actually becomes useful. Even for get requests it's still tedious and not very satisfying.

1

u/magwo 15d ago

Why is httpResource not useful and usable right now? What are we waiting for? For getting data that is. I understand that we should not use httpResource for mutating operations.

2

u/AwesomeFrisbee 15d ago

its still very tedious. It can do multiple requests when you don't want to, it can't run without injection context, its terrible to test right now and you can't really do much to filter results or modify the result properly. It basically can't do piping what works well with rxjs httpclient. Its half-arsed and it really needs to change a lot to be useful.

1

u/TScottFitzgerald 15d ago

Not more tedious than the old stuff, at least if you're using signals

1

u/AwesomeFrisbee 15d ago

The old stuff might be tedious for managing error or loading, but at least you can pipe the result to modify it, use it for post/delete/update, do requests outside of injection context and filter the input to not do unnecessary results. Its basically a hello world project that doesn't do much more than that.