Aurelia: [WIP] Router Use Cases [RFC]

Created on 21 Oct 2018  Â·  10Comments  Â·  Source: aurelia/aurelia

  • [x] [Dynamic Redirect](https://github.com/aurelia/router/issues/585)
  • [ ] [Router Passthrough](https://github.com/aurelia/router/issues/527) (also)
  • [ ] [View Caching](https://github.com/aurelia/router/issues/173)
  • [ ] [Prevent Exit](https://github.com/aurelia/router/issues/564)
  • [x] [Custom Titles](https://github.com/aurelia/router/issues/218)

Dynamic Redirect

const redirect = (from, to, next) => next({ redirect: 'new' });
router.mapRoutes([ { route: 'old', before: redirect } ]);

Prevent Exit

const preventExit = (from, to, next) => next(??? ? null : 'home')
router.mapRoutes([ { route: '', name: 'home' ]);
router.before = [preventExit];

Custom Titles

router.buildTitle = (instructions) => instructions.reverse().map(i => i.title).join(' | ');
API In discussion Needs more feedback Needs more info RFC Router

Most helpful comment

Use case
generate route to a sibling router
https://github.com/aurelia/router/issues/89

All 10 comments

Use case:
A dynamically loaded component has configureRouter and router-view

some developers would like to generate events on child routers
https://github.com/aurelia/router/issues/293

a case to look and test for with child router and redirect params
https://github.com/aurelia/router/issues/66

Use case
generate route to a sibling router
https://github.com/aurelia/router/issues/89

Cancelling a navigation instruction with a redirect raises inconsistent navigation events
https://github.com/aurelia/router/issues/177

Links containing hash anchor tags in URL not supported
https://github.com/aurelia/router/issues/225

Add helpers for dynamically matching paths
https://github.com/aurelia/router/issues/249

Load route viewModel module from external location or via alternative resolve strategy
https://github.com/aurelia/router/issues/379

Re https://github.com/aurelia/router/issues/379
Commenting here because that issue was closed, but it would be a wishlist item for a backport...

Similar to how globalResources lets you pass the constructor for a resource now instead of the module path,

It would be great if you could pass an async function to the route config that resolves to the viewmodel constructor (ie container key?) to use for the route.

We are trying to avoid things breaking due to moved or renamed modules, and this is one of the last areas in our app where a string is still required.

Being able to pass a function that returns (await import("module-path")).ViewModelX would allow the build to catch errors (or the IDE to do the refactoring).

That's a wonderful idea, thank you for the note.

On Thu, Apr 25, 2019, 20:17 Kris Dages notifications@github.com wrote:

Re aurelia/router#379 https://github.com/aurelia/router/issues/379
Commenting here because that issue was closed, but it would be a wishlist
item for a backport...

Similar to how globalResources lets you pass the constructor for a
resource now instead of the module path,

It would be great if you could pass an async function to the route config
that resolves to the viewmodel constructor (ie container key?) to use for
the route.

We are trying to avoid things breaking due to moved or renamed modules,
and this is one of the last areas in our app where a string is still
required.

Being able to pass a function that returns (await import
("module-path")).ViewModelX would allow the build to catch errors (or the
IDE to do the refactoring).

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/aurelia/aurelia/issues/239#issuecomment-486881806,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA5K5P3KZS666S565VBGRGTPSJC2NANCNFSM4F6JC6WQ
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LarsKemmann picture LarsKemmann  Â·  12Comments

davismj picture davismj  Â·  11Comments

HamedFathi picture HamedFathi  Â·  13Comments

Vheissu picture Vheissu  Â·  3Comments

xenoterracide picture xenoterracide  Â·  12Comments