Skip to content

feat(signals): add resource extensions#5167

Open
markostanimirovic wants to merge 2 commits into
mainfrom
feat/signals/extend-resource
Open

feat(signals): add resource extensions#5167
markostanimirovic wants to merge 2 commits into
mainfrom
feat/signals/extend-resource

Conversation

@markostanimirovic

Copy link
Copy Markdown
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

Closes #5126

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Comment thread projects/www/src/app/pages/guide/signals/resource-extensions.md
@markostanimirovic markostanimirovic force-pushed the feat/signals/extend-resource branch from cd35ccf to 2c1cc39 Compare June 16, 2026 15:51
Comment thread modules/signals/resource/src/extensions/with-value-on-error.ts
@rainerhahnekamp rainerhahnekamp force-pushed the feat/signals/extend-resource branch from cbd57d5 to 2dc56b6 Compare June 23, 2026 20:33
@markostanimirovic markostanimirovic force-pushed the feat/signals/extend-resource branch from 5cecd0b to 08b7876 Compare June 29, 2026 21:32
- **Value on loading** - when a resource reloads, `value()` resets to `undefined` until the new data arrives.
- **Value on error** - when a resource enters the error state, reading `value()` throws.

The `extendResource` function, together with the built-in extensions, addresses both cases without losing access to the APIs of more specific resource types, such as `WritableResource`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would directly address here the open question, namely the difference to the native snapshots. To me the additional benefits are the ability of having

  1. A WritableSignal
  2. The option to define them globally.

So I would rephrase it like

Suggested change
The `extendResource` function, together with the built-in extensions, addresses both cases without losing access to the APIs of more specific resource types, such as `WritableResource`.
Unlike the native `resourceFromSnapshots` function, which downcasts the output to a base `Resource`, `extendResource` can be configured globally and fully preserves the capabilities of writable types like `WritableResource`.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd avoid mentioning resourceFromSnapshot in case this limitation gets solved on the Angular side in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC(@ngrx/signals): Resource Integration Part 1 - Introduce Extend Resource APIs

4 participants