You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/with-entity-resources.md
+3-24Lines changed: 3 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,32 +88,11 @@ This exposes per-resource members with the resource name as a prefix:
88
88
89
89
## Error Handling
90
90
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.
92
92
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`.
96
94
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).
Copy file name to clipboardExpand all lines: docs/docs/with-resource.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,10 +85,9 @@ With named resources, each resource gets prefixed properties:
85
85
86
86
## Error Handling
87
87
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.
89
90
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.
92
91
To prevent resource failures from blocking the store, the Toolkit provides some strategies to handle errors.
93
92
94
93
```ts
@@ -106,11 +105,11 @@ withResource(
106
105
107
106
Options:
108
107
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 valuewill be returned.
111
110
1.`'native'`. No special handling is provided, inline with default error behavior.
112
111
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).
0 commit comments