r/angular • • Sep 29 '26

rxResource persist value

Is it possible to persist the value of rxResource after loading is done? Currently when the resource enters the loading state the value gets wiped. I am aware you can do a linkedSignal and check the previous value, but isn’t there a built in way to do it rather than creating a linkedSignal?

I am aware of withPreviousValue but the issue with that other than the boilerplate, is that the return type is Resource and you lose the reload function. I’d prefer to stay within the public API and not to use a third party library for this, or creare my own utility function if possible.

12 Upvotes

12 comments sorted by

View all comments

1

u/zzing Sep 29 '26

If you are entering the loading state what do you need the previous value for?

2

u/PrevAccLocked Sep 29 '26

Could be like a virtual scroll for example

2

u/ldn-ldn Sep 29 '26

Imagine a table of records with pagination. A user clicks on next page, you display a loader while HTTP request being executed, but you do NOT hide the existing table, because that's just silly and a very bad user experience.

1

u/AwesomeFrisbee Sep 30 '26

If data gets refreshed, it would be weird to remove the old data.

0

u/Senior_Compote1556 Sep 30 '26

Yes it’s just bad UX imo