feat(router): make route resources reactive and support parallel depe… by atscott · Pull Request #70587 · angular/angular · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 163 additions & 38 deletions adev/src/content/guide/routing/data-fetching-with-resources.md
14 changes: 7 additions & 7 deletions adev/src/content/guide/routing/read-route-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ export class Product {

The `ActivatedRoute` can provide different information about the route. Some common properties include:

| Property | Details |
| :------------ | :-------------------------------------------------------------------------------------------------------------------------------- |
| `url` | An `Observable` of the route paths, represented as an array of strings for each part of the route path. |
| `data` | An `Observable` that contains the `data` object provided for the route. Also contains any resolved values from the resolve guard. |
| `params` | An `Observable` that contains the required and optional parameters specific to the route. |
| `queryParams` | An `Observable` that contains the query parameters available to all routes. |
| `resources` | An optional record of `Resource` instances defined on the route (when `withRouterResources` is enabled). |
| Property | Details |
| :------------ | :-------------------------------------------------------------------------------------------------------------------------------------------- |
| `url` | An `Observable` of the route paths, represented as an array of strings for each part of the route path. |
| `data` | An `Observable` that contains the `data` object provided for the route. Also contains any resolved values from the resolve guard. |
| `params` | An `Observable` that contains the required and optional parameters specific to the route. |
| `queryParams` | An `Observable` that contains the query parameters available to all routes. |
| `resources` | An optional `Signal` containing the map of `Resource` instances defined on or inherited by the route (when `withRouterResources` is enabled). |

Check out the [`ActivatedRoute` API docs](/api/router/ActivatedRoute) for a complete list of what you can access with in the route.

Expand Down
7 changes: 4 additions & 3 deletions goldens/public-api/router/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class ActivatedRoute {
get pathFromRoot(): ActivatedRoute[];
get queryParamMap(): Observable<ParamMap>;
queryParams: Observable<Params>;
resources?: ResourceResult;
resources?: Signal<ResourceResult>;
get root(): ActivatedRoute;
get routeConfig(): Route | null;
snapshot: ActivatedRouteSnapshot;
Expand All @@ -73,7 +73,7 @@ export class ActivatedRouteSnapshot {
// (undocumented)
get queryParamMap(): ParamMap;
queryParams: Params;
resources?: ResourceResult;
resources?: Signal<ResourceResult>;
get root(): ActivatedRouteSnapshot;
readonly routeConfig: Route | null;
get title(): string | undefined;
Expand Down Expand Up @@ -672,7 +672,8 @@ export interface ResourceContext {
fragment: Signal<string | null>;
params: Signal<Params>;
queryParams: Signal<Params>;
snapshot: ActivatedRouteSnapshot;
resources: Signal<ResourceResult>;
routeConfig: Route | null;
}

// @public
Expand Down
2 changes: 1 addition & 1 deletion packages/router/src/directives/router_outlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ export class RoutedComponentInputBinder {
...queryParams,
...params,
...data,
...(activatedRoute.resources || {}),
...activatedRoute?.resources?.(),
};
// Get the first result from the data subscription synchronously so it's available to
// the component as soon as possible (and doesn't require a second change detection).
Expand Down
14 changes: 10 additions & 4 deletions packages/router/src/models.ts
Loading