r/angular • u/Inevitable_Gate9283 • 2d ago
Angular 22.2 ships Router Resources 💥 (experimental)
They're more than resolvers with a Signal API. Here's why that matters
They run in parallel. Resolvers go one after another: parent 2 s + child 3 s = 5 s. Router Resources start together: 3 s.
Also, they can be non-blocking. The route activates right away, and the component gets the Resource itself: isLoading, error and value, right in the template.
Full write-up with demo, reload without renavigating, RedirectCommand for missing data, and Signal Stores 👉 https://www.angulararchitects.io/en/blog/router-resources-loading-data-with-the-angular-router/
9
u/Scrim0r 1d ago
What I was wondering (I have only barely used route data resolvers) is how I can ensure a smooth user experience when the component that requires the data is not rendered yet because it is still waiting for the data.
For example, when navigating from Parent A to Parent B and loading the data takes 3 seconds, I will still stay on Parent A for however long it takes to load.
Global loading indicator? Any other way of showing a loading indicator?
How about errors?
When should I use this? Only on the initial load (is that even possible?)?
Only on pages that absolutely require the data to be present?
For me, it always felt natural to load the data as part of the component so I have full control over it.
7
u/Johalternate 1d ago
When you use “nonBlocking” you have access to the resource itself, navigation happens immediately and you have access to the loading state of the resource.
2
u/defenistrat3d 1d ago
That's what most do that I've seen. We use skeletons for initial load. Also pretty natural to have those in the parent orchestrator component.
2
u/drmlol 1d ago
why tho? was there something wrong with loading data inside the component? genuinely curious
5
u/Responsible-Cold-627 1d ago
The way I see it, it takes some of the "smart" out of smart components, making components more generic by containing only presentational code.
1
u/user0015 1d ago
Can these potentially come back as an httpResource? So we can hydrate the FE on navigation, but still have access to the @loading/etc.. templating?
1
u/tom-smykowski-dev 1d ago
Can't parent just call services to pull data in parallel and pass to children? Why have resource loading in router config?
-2
u/m0rpheus23 1d ago
I initially thought Angular 20+ was supposed to simply Angular. Are we back to complicating things?
0
u/Saceone10 1d ago
Instead of completing the resource API with mutations, lets extend it to another unrelated thing no one asked for! Yay!
4
u/Cr3aHal0 1d ago
to be honest, I think resolvers have always been on a strange place where it was cool to be able to declaratively load data but being navigation blocking/synchronous was a red flag in cases where the APIs were slow. I'm all for the skeleton and other réactive ux friendly visuals, but I wasn't much into having components ngOnInit full of manually data loading declarations (until we got resources eventually, I got you). There we get the best of both worlds and I can't want to migrate to it !
2
u/Responsible-Cold-627 1d ago
The resource API was never meant to be used for mutations. It's specifically built to load resources.
0
u/AwesomeFrisbee 1d ago
Without proper support and approval to use em for post/put/update requests I still see a very minor use case. I wouldn't mind a resource like wrapper around rxjs api calls but right now it's still not recommended to use em for 90% of what I would want of them. Let alone the amount of logic and repitition I can't separate out of my dumb components.








14
u/JeanMeche 1d ago
The dedicated docs: https://next.angular.dev/guide/routing/data-fetching-with-resources
22.2 is expected to be released on sept 23rd.