Skip to content

refactor(router): add support for non-blocking router resources - #70211

Draft
atscott wants to merge 2 commits into
angular:mainfrom
atscott:resourcestack1
Draft

refactor(router): add support for non-blocking router resources #70211
atscott wants to merge 2 commits into
angular:mainfrom
atscott:resourcestack1

Conversation

@atscott

@atscott atscott commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Introduces support for route-level resources via the resources property on route definitions, enabled with withRouterResources().

Router resources provide a reactive, signal-based alternative to resolvers, allowing routes to declare resources tied to route parameters and route lifecycle:

  • The resources function executes during navigation transitions within an injection context scoped to the route (_localInjector).
  • It receives a ResourceContext containing signals for params, queryParams, fragment, and data, alongside the static snapshot.
  • For newly created routes, resources runs once and attaches to ActivatedRoute.resources. For reused routes, parameter signals update reactively to trigger new data fetches while keeping resource references stable.
  • Wrapped resources (routerResource) provide transactional stability: snapshots are frozen during active navigations to prevent UI jitter, unfreezing on NavigationEnd.
  • On cancelled navigations or errors, rollback recovery retains the frozen snapshot until reverted signals settle, avoiding flashes of loading state. Manual reloads are rejected while frozen.
  • Local injectors are automatically cleaned up if navigations are cancelled or rolled back.

Note that this commit only implements non-blocking resources (marked with nonBlocking()), deferring blocking resource resolution to future work to keep the initial changeset smaller and less complex.

@ngbot ngbot Bot added this to the Backlog milestone Aug 14, 2026
@atscott
atscott force-pushed the resourcestack1 branch 4 times, most recently from f1a4e5f to 45c2c1f Compare August 14, 2026 20:05
… feature

Activated Route Injector feature was developed for resources. This moves the internal
naming (files and vars) to reflect this now that we have landed the core bits of plumbing
and are ready to implement router resources.
@atscott
atscott force-pushed the resourcestack1 branch 2 times, most recently from 7a8b3ff to 11d3f43 Compare August 14, 2026 21:23
Introduces support for route-level resources via the `resources` property on route definitions, enabled with `withRouterResources()`.

Router resources provide a reactive, signal-based alternative to resolvers, allowing routes to declare resources tied to route parameters and route lifecycle:
- The `resources` function executes during navigation transitions within an injection context scoped to the route (`_localInjector`).
- It receives a `ResourceContext` containing signals for `params`, `queryParams`, `fragment`, and `data`, alongside the static `snapshot`.
- For newly created routes, `resources` runs once and attaches to `ActivatedRoute.resources`. For reused routes, parameter signals update reactively to trigger new data fetches while keeping resource references stable.
- Wrapped resources (`routerResource`) provide transactional stability: snapshots are frozen during active navigations to prevent UI jitter, unfreezing on `NavigationEnd`.
- On cancelled navigations or errors, rollback recovery retains the frozen snapshot until reverted signals settle, avoiding flashes of loading state. Manual reloads are rejected while frozen.
- Local injectors are automatically cleaned up if navigations are cancelled or rolled back.

Note that this commit only implements non-blocking resources (marked with `nonBlocking()`), deferring blocking resource resolution to future work to keep the initial changeset smaller and less complex.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant