router icon indicating copy to clipboard operation
router copied to clipboard

Add support for multiple actions on a route

Open marcushellberg opened this issue 4 years ago • 1 comments

In some cases it would be useful to be able to run a sequence of actions for a route, like:

  1. Authenticate
  2. Import module

Maybe action could accept an array that it runs in order. If any item returns a command, it would stop there.

{
  path: '/foo',
  component: 'x-foo',
  action: [authGuard, () => import('./components/x-foo')]
}

marcushellberg avatar Dec 07 '20 21:12 marcushellberg

Suggestion: Add a helper method (say sequence()) that can be imported from the @vaadin/router package and used like:

{
  path: '/foo',
  component: 'x-foo',
  action: sequence(authGuard, () => import('./components/x-foo'))
}

vlukashov avatar Dec 08 '20 12:12 vlukashov