Skip to content

Conversation

@michael-small
Copy link
Collaborator

Assuming the following PR for resource error behavior in the resource features is merged: #270

@michael-small michael-small self-assigned this Jan 4, 2026
@michael-small michael-small added the documentation Improvements or additions to documentation label Jan 4, 2026
@michael-small michael-small marked this pull request as draft January 4, 2026 23:59
@michael-small
Copy link
Collaborator Author

Caretaker note: once the actual error handling PR is merged, update the two doc pages' links to point at the jsdocs for the error handling behavior deep explanation


## Error Handling

The behavior of Angular's resources' error handling and the NgRx SignalStore's `getState/patchState` required `withEntityResource` to approach error handling
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TODO - I phrased this so weird. Once the v21 blog post is more fleshed out, take what was written there and replace some of this awkwardness.

Copy link
Collaborator

@rainerhahnekamp rainerhahnekamp left a comment

Choose a reason for hiding this comment

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

Good, good, just a few remarks.

- **Resource members**: `todosValue()`, `todosStatus()`, `todosError()`, `todosIsLoading()`; `projectsValue()`, ...
- **Entity members**: `todosIds()`, `todosEntityMap()`, `todosEntities()`; `projectsIds()`, `projectsEntityMap()`, `projectsEntities()`

## Error Handling
Copy link
Collaborator

Choose a reason for hiding this comment

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

The complete withEntityResource is based on the undefined value strategy. I think we just need to here a quick note on that and link to withResource for further details.

Users cannot change the error handling here, since withEntityResource uses the resource internally. It is an implementation detail so to say.


Starting in NgRx Toolkit v20.6.0, error handling now has more resilient options.

The behavior of Angular's resources' error handling and the NgRx SignalStore's `getState/patchState` required `withResource` to approach error handling
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wouldn't be that specific. I would just say sometihng like

that the error throwing behavior of the native resource causes a deadlock in the error case. That's why withResource comes with a different error handling, which doesn't throw.


Options:

1. `'undfined value'` (default). In the event of an error, the resource's value will be `undefined`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
1. `'undfined value'` (default). In the event of an error, the resource's value will be `undefined`
1. `'undefined value'` (default). In the event of an error, the resource's value will be `undefined`

Options:

1. `'undfined value'` (default). In the event of an error, the resource's value will be `undefined`
1. `'previous value'`. Provided the resource had a previous value, that previous value will be returned. If not, an error is thrown.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wouldn't mention the condition that it only returns if a previous value exists. It just returns the previous value.

A resource always has a value in its initial state. The implementation needs to consider a "non-realsitic" scenario because of TypeScript.

@michael-small michael-small marked this pull request as ready for review January 16, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation v21

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PSA: v21 plan - 20.6.0 works with NgRx v21, Toolkit v21 pending review

3 participants