Describe the problem that you experienced
Angular 22 introduced the possibility of chaining resources thanks to the chain property of ResourceParamsContext.
I'm a bit surprised it's not experimental, given that it's quite new compared to the resource API.
Except for the referenced documentation, I haven't found any documentation for this chaining feature for resources, in the guide about resources. And this feature looks more complex than it first looks like to me.
Enter the URL of the topic with the problem
https://angular.dev/guide/signals/resource
Describe what you were looking for in the documentation
What I would expect to find is the following.
The purpose of this chain parameter, and how to chain two resources together.
In particular, explain how to deal with chain() returning undefined (I don't understand why its return type is not <Exclude<T, undefined> like value() does when hasValue() is true, since it only returns the value of the source resource if it is available).
Whether if it's a good idea or an anti-pattern to use this for synchronously mapping the value of a resource, even though the loader is async. For example:
const numericResource: ResourceRef<number | undefined> = resource(...);
const stringResource: ResourceRef<string | undefined> = resource({
params: ({ chain }) => chain(numericResource),
loader: async ({ params: num }) => `${num}`
});
If it's an anti-pattern, document how to better do it (because it looks to me like a common usecase).
Describe the actions that led you to experience the problem
No response
Describe what you want to experience that would fix the problem
No response
Add a screenshot if that helps illustrate the problem
No response
If this problem caused an exception or error, please paste it here
If the problem is browser-specific, please specify the device, OS, browser, and version
Provide any additional information here in as much as detail as you can
Describe the problem that you experienced
Angular 22 introduced the possibility of chaining resources thanks to the
chainproperty of ResourceParamsContext.I'm a bit surprised it's not experimental, given that it's quite new compared to the resource API.
Except for the referenced documentation, I haven't found any documentation for this chaining feature for resources, in the guide about resources. And this feature looks more complex than it first looks like to me.
Enter the URL of the topic with the problem
https://angular.dev/guide/signals/resource
Describe what you were looking for in the documentation
What I would expect to find is the following.
The purpose of this
chainparameter, and how to chain two resources together.In particular, explain how to deal with
chain()returningundefined(I don't understand why its return type is not<Exclude<T, undefined>likevalue()does whenhasValue()is true, since it only returns the value of the source resource if it is available).Whether if it's a good idea or an anti-pattern to use this for synchronously mapping the value of a resource, even though the loader is async. For example:
If it's an anti-pattern, document how to better do it (because it looks to me like a common usecase).
Describe the actions that led you to experience the problem
No response
Describe what you want to experience that would fix the problem
No response
Add a screenshot if that helps illustrate the problem
No response
If this problem caused an exception or error, please paste it here
If the problem is browser-specific, please specify the device, OS, browser, and version
Provide any additional information here in as much as detail as you can