Skip to content

Commit f8152f4

Browse files
committed
docs: apply error copy to withEntityResource
1 parent 00e2d14 commit f8152f4

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

docs/docs/with-entity-resources.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,31 @@ This exposes per-resource members with the resource name as a prefix:
8888

8989
## Error Handling
9090

91-
<!-- TODO - mention error handling strategies -->
91+
The behavior of Angular's resources' error handling and the NgRx SignalStore's `getState/patchState` required `withEntityResource` to handle error handling with a particular strategy.
92+
To prevent resource failures from blocking the store, the Toolkit provides some strategies to handle errors.
93+
94+
```ts
95+
withEntityResource(
96+
() => ({
97+
id: resource({
98+
loader: () => Promise.resolve(1),
99+
defaultValue: 0,
100+
}),
101+
}),
102+
// Other values: 'native' and 'previous value'
103+
{ errorHandling: 'undefined value' }, // default if not specified
104+
),
105+
```
106+
107+
Options:
108+
109+
1. `'undfined value'` (default). In the event of an error, the resource's value will be `undefined`
110+
1. `'previous value'`. Provided the resource had a previous value, that previous value will be returned. If not, an error is thrown.
111+
1. `'native'`. No special handling is provided, inline with default error behavior.
112+
113+
<!-- TODO - update link when the code is merged -->
114+
115+
Under the hood, `'previous value'` and `'undefined value'` proxy the value. For a detailed explanation for why this is done and what a more longterm solution may be with some framework enhancements, check out the [JSDoc for the error handling strategy](https://google.com).
92116

93117
## Component Usage
94118

docs/docs/with-resource.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ Options:
107107
1. `'previous value'`. Provided the resource had a previous value, that previous value will be returned. If not, an error is thrown.
108108
1. `'native'`. No special handling is provided, inline with default error behavior.
109109

110-
<!-- TODO - mention both approaches with pros & cons like the jsdoc? link to it? IMO - mention we use a proxy approach while Angular works on error handling and then link to jsdoc -->
111-
<!-- TODO - PROPOSED COPY -->
110+
<!-- TODO - update link when the code is merged -->
112111

113112
Under the hood, `'previous value'` and `'undefined value'` proxy the value. For a detailed explanation for why this is done and what a more longterm solution may be with some framework enhancements, check out the [JSDoc for the error handling strategy](https://google.com).
114113

0 commit comments

Comments
 (0)