Is it possible to globally change the default route activation strategy?
I would like to define activationStrategy.replace for all routes without having to write the following every time:
{ route: 'edit', name: 'edit', moduleId: PLATFORM.moduleName('./edit'), activationStrategy: activationStrategy.replace }
For AU1 would using a pipeline function do what you want?
https://aurelia.io/docs/routing/configuration#pipelines
1 Like
Thanks a lot, that’s exactly what I need!
class PreActivateStep
{
run(navigationInstruction: NavigationInstruction, next: Next): Promise<any>
{
const routeConfig = navigationInstruction.config;
routeConfig.activationStrategy = routeConfig.activationStrategy || activationStrategy.replace;
return next();
}
}
While this is great to save some extra typing keep in mind this aspect oriented approach might also come with a hidden-details-issue. Similar as with extension methods in C# if they hide business logic contrary to pure syntactical sugar it’s easy to forget once you need an exception.
The main issue I see here is that the definition of routes and the activationStep aren’t collocated. So a simple function which would mutate given objects with the default strategy might be an extra import and function call but be more explicit
You did well with respecting a predefined activation strategy if present though 
Just my 2 cents