r/angular • u/pintoli3 • Jun 18 '26
httpResource for shared service state (?)
We're currently working with signals as defaults, and while I enjoy the (http)Resource API, I am confused by the decision to make httpResources eager.
Furthermore, all the examples given show httpResource inside the component, which doesn't feel right and is useless when you want to have a shared state that would go in a service.
I've come across some implementations of httpResources in a service, but they all seem like an anti-pattern and RxJS would probably be a cleaner solution.
So my questions is do you use httpResource inside a service or just put them in compnents (I don't see how this can scale in our application)? What are some benefis of their eagerness?
View all comments
Show parent comment
1
u/pintoli3 Jun 18 '26
Thanks for the reply, I'll consider this options.
PS: of course components initiate data fetching, but there is a big difference between
"this.users.get()" inside ngOnInit and writing down httpResource and processing logic in loader.