Repository navigation
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:
Current behavior
The Angular router's resolve functionality does not seem to support a fundamental use-case: explicitly invalidating and refreshing some resolved data when the application knows it has changed.
For example, consider I have a route /project/:id with a resolver that loads the project data from an API and makes it available to a number of components in sub-pages.
Consider I also have a child page, "Rename Project", that makes a change via the API that invalidates the resolved project data. At this point, I need to force a reload that also refreshes the project data.
Or, consider I have a WebSocket connection that streams updates from the server and notifies my app when the project has been renamed by another user.
Navigating to another page will not re-run the resolver. Instead, the originally resolved data is returned. This caching is expected and helpful in most cases, but only if there is a way to invalidate the cached data when necessary.
Expected behavior
There should a way to tell the router to re-run a resolver when you know its data has changed. E.g. in my RenameProjectComponent controller:
async renameProject(newName: string) {
await this.projectApi.renameProject(this.project.id, newName);
this.activatedRoute.invalidateData('project');
this.router.navigate(['project', this.project.id]);
}The call to router.navigate(...) would then re-run the project resolver.
Minimal reproduction of the problem with instructions
In this example, a "rename project" page changes the project entity in an underlying service. However, the original version of the entity provided by the resolver continues to be used, because there is no way for the app to signal to the router that it needs to fetch the updated project.
What is the motivation / use case for changing the behavior?
In the real world, data changes, and caches need to be invalidated. Without this ability, the Angular router's resolve functionality is little more than a toy.
Environment
Angular version: 6.0.0
Browser:
N/A
Activity
liesahead commentedon Sep 21, 2020
Well, 2 years.. Probably if status is set to medium it means it will never be implemented 😞
angular-robot commentedon Jun 5, 2021
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
angular-robot commentedon Jun 25, 2021
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
angular-automatic-lock-bot commentedon Jul 24, 2022
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.