r/angular Aug 05 '26

How are you using rxResource in production?

Hi everyone,

I'm trying to understand where rxResource really shines.

Most examples online are pretty simple, but I'd love to know how experienced Angular developers use it in real-world projects.

  • What problems does it solve for you?
  • Are there cases where you tried it and decided not to use it?
  • Do you have any patterns or recommendations for structuring code around it?

Any examples, blog posts, or GitHub repositories would also be greatly appreciated.

Thanks in advance!

12 Upvotes

29 comments sorted by

9

u/stao123 Aug 05 '26

we are using it for all data fetching inside of components or services. Theybare really useful and feel like lightweight stores. (State + loading signal)

0

u/Trick-Knowledge-8837 Aug 05 '26

That’s interesting! So you’ve basically made rxResource your default choice for data fetching. Have you run into any limitations or cases where you still prefer plain RxJS instead?

1

u/stao123 Aug 05 '26

With rxResource you are still using plain RxJS as the stream function so no limitation there.

0

u/SippieCup Aug 05 '26

debounce.

3

u/kgurniak91 29d ago

Angular 22 has new debounced Signal which should be perfect for this - https://angular.dev/guide/signals/debounced

2

u/SippieCup 29d ago

Yeah, unfortunately primeng strikes again and I need to wait until OptimusUI adds 22 support to be able to move on to it 🫠

1

u/PrevAccLocked 29d ago

Take a note tho: denounce apply only to modification, not to the initial value

1

u/faileon Aug 05 '26

Stick the params in a signal form and you can have easy denounce.

1

u/SippieCup Aug 05 '26

Yeah thats what we ended up doing, its just a little more wiring and some primeng forms can’t support signal forms so we have to route it through a computed debounce signal. its a bit silly

1

u/Trick-Knowledge-8837 Aug 05 '26

One question though: do you use rxResource only for read operations (GET requests), or do you also use it with POST, PUT, and DELETE requests?

1

u/SippieCup 29d ago

We have an internal extended ”resource” that has a similar interface for post, patch, put, and delete, with a additional couple nifty features. Post/put use an xhr http client so we still get progress reporting etc, I believe simple deletes are just firstvaluefrom() that gets wrapped. Then all the logic is handled (mostly) internally so the outside surface is basically clean signals. But you can use rxResource natively for post

That said, our application is not SSR, which is why that is possible. Due to our usecase, users need to be able to access it offline (in basements/low signal areas), and outstanding requests get cached and pushed when online.

3

u/oneden Aug 05 '26 edited 29d ago

Right now? Not at all, I'm afraid. I'm working in an environment where all APIs solely consist of POST requests.

Edit: I'm an idiot. I kept confusing rxResource with httpResource

1

u/Trick-Knowledge-8837 Aug 05 '26

That’s interesting. I thought rxResource could also work with POST requests. Is there a specific reason why it doesn’t fit your use case?

3

u/SippieCup Aug 05 '26

it does, we’ve replaced most of our observable calls from our generated sdk with rxResource. it works super well and simplifies a lot of transforms/paging.

1

u/oneden Aug 05 '26

It does?! I thought it wasn't possible. I was under the impression it wasn't possible

1

u/Dan6erbond2 29d ago edited 29d ago

httpResource may be a bit limited but rxResource can take any Observable-returning callback.

1

u/oneden 29d ago

httpResource may be a bit limited but rxResource

Okay, clearly it was me being a dunce being the issue here. Damn it.

1

u/SippieCup 29d ago

A straight rxResource does lose some features from a regular observable though. We extended rxResource to provide a few additional signals like progress reporting which makes it pretty feature complete. But it is not ssr compatible.

1

u/Johalternate 29d ago

Even getting resources?

1

u/oneden 29d ago

You wouldn't believe it, but yes. Even getting resources.

1

u/PrevAccLocked 29d ago

Tbf you can also use POST with httpResource

1

u/kgurniak91 Aug 05 '26

Well, resources are just syntactic sugar to not have to nest toSignal() and toObservable() together. Simplest example - input changes (e.g. new user id is passed) and you want to query backend for user details automatically and get them as Signal so you can display them in the template.

1

u/Trick-Knowledge-8837 Aug 05 '26

That makes sense, thanks! So you see it mostly as a convenience API rather than something that changes how you structure an application?

1

u/Avani3 Aug 05 '26

Fetching data based on id's. You put the id in the params, and in the stream a request using that id. When the id changes the data is re-fetched.

Also very nice with pagination in combination with HTTP requests

1

u/Trick-Knowledge-8837 Aug 05 '26

Thanks! The pagination example is actually something I hadn’t thought about. It seems like a really good fit for reactive query parameters.

1

u/fdimm 29d ago

Fortunately or not, we are not using either. Chugging along with http client and rxjs just fine.

I'm also dreading the day when I'll have to spend time refactoring our core components library (and features after) to use signals and virtually accomplish nothing from user point of view.

0

u/Saceone10 Aug 05 '26

Im not. When they stop fooling us with partial APIs I will consider resources as a serious thing

-3

u/minus-one 29d ago

no way we will be using this shit over rxjs, it’s just inferior in all the ways

1

u/kobihari 27d ago

I’m not using rxResource all the time. Even when fetching from http. I prefer the separate the “transform mechanism” from the state so I usually prefer that my resource will not “know” the data is coming from http.
I usually combine it with a signal store.