feat(router): add predicate function mode for runGuardsAndResolvers (#27682)
This option means guards and resolvers will ignore changes when a provided predicate function returns `false`. This supports use cases where an application needs to ignore some param updates but not others. For example, changing a sort param in the URL might need to be ignored, whereas changing the a `project` param might require re-run of guards and resolvers. Related to #26861 #18253 #27464 PR Close #27682
This commit is contained in:
@ -147,6 +147,9 @@ function getRouteGuards(
|
||||
function shouldRunGuardsAndResolvers(
|
||||
curr: ActivatedRouteSnapshot, future: ActivatedRouteSnapshot,
|
||||
mode: RunGuardsAndResolvers | undefined): boolean {
|
||||
if (typeof mode === 'function') {
|
||||
return mode(curr, future);
|
||||
}
|
||||
switch (mode) {
|
||||
case 'pathParamsChange':
|
||||
return !equalPath(curr.url, future.url);
|
||||
|
Reference in New Issue
Block a user