Skip to content

Commit 964a75f

Browse files
committed
docs: feedback for with(Entity)Resource
1 parent 88ff856 commit 964a75f

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

docs/docs/with-entity-resources.md

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -88,32 +88,11 @@ This exposes per-resource members with the resource name as a prefix:
8888

8989
## Error Handling
9090

91-
Starting in NgRx Toolkit v20.6.0, error handling now has more resilient options.
91+
Starting in NgRx Toolkit v20.6.0, error state handling for `withResource` and `withEntityResources` was enhanced.
9292

93-
The behavior of Angular's resources' error handling and the NgRx SignalStore's `getState/patchState` required `withEntityResource` to approach error handling
94-
with a particular strategy unique to the intersection of resources and the Signal Store.
95-
To prevent resource failures from blocking the store, the Toolkit provides some strategies to handle errors.
93+
In the event of an error in a resource declared in `withEntityResource`, the resource's value will be `undefined`.
9694

97-
```ts
98-
withEntityResource(
99-
() => ({
100-
id: resource({
101-
loader: () => Promise.resolve(1),
102-
defaultValue: 0,
103-
}),
104-
}),
105-
// Other values: 'native' and 'previous value'
106-
{ errorHandling: 'undefined value' }, // default if not specified
107-
),
108-
```
109-
110-
Options:
111-
112-
1. `'undfined value'` (default). In the event of an error, the resource's value will be `undefined`
113-
1. `'previous value'`. Provided the resource had a previous value, that previous value will be returned. If not, an error is thrown.
114-
1. `'native'`. No special handling is provided, inline with default error behavior.
115-
116-
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://github.com/angular-architects/ngrx-toolkit/blob/main/libs/ngrx-toolkit/src/lib/with-resource.ts#L402).
95+
For further details, check out the error handling section of [`withResource`](./with-resource.md#error-handling).
11796

11897
## Component Usage
11998

docs/docs/with-resource.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ With named resources, each resource gets prefixed properties:
8585

8686
## Error Handling
8787

88-
Starting in NgRx Toolkit v20.6.0, error handling now has more resilient options.
88+
The error throwing behavior of the native `resource` causes a deadlock in the error case.
89+
That's why `withResource` (as of NgRx Toolkit v20.6.0) comes with a different error handling strategy, which doesn't throw.
8990

90-
The behavior of Angular's resources' error handling and the NgRx SignalStore's `getState/patchState` required `withResource` to approach error handling
91-
with a particular strategy unique to the intersection of resources and the Signal Store.
9291
To prevent resource failures from blocking the store, the Toolkit provides some strategies to handle errors.
9392

9493
```ts
@@ -106,11 +105,11 @@ withResource(
106105

107106
Options:
108107

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.
108+
1. `'undefined value'` (default). In the event of an error, the resource's value will be `undefined`
109+
1. `'previous value'`. The resource's previous value will be returned.
111110
1. `'native'`. No special handling is provided, inline with default error behavior.
112111

113-
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://github.com/angular-architects/ngrx-toolkit/blob/main/libs/ngrx-toolkit/src/lib/with-resource.ts#L402).
112+
Under the hood, `'previous value'` and `'undefined value'` proxy the value. For a detailed explanation for why this is done, check out the [JSDoc for the error handling strategy](https://github.com/angular-architects/ngrx-toolkit/blob/main/libs/ngrx-toolkit/src/lib/with-resource.ts#L402).
114113

115114
## Component Usage
116115

0 commit comments

Comments
 (0)