swipely / aviator

Aviator is a single-page front-end router built for modularity.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow string-only target definition for sibling-level matches

barnabyc opened this issue · comments

Currently to match:

          '/retention': {
            target: targets.menuRetentionRouteTarget,
            '/*': 'beforeAll',
            '/':  'index'
          },

one has to write it as:

          '/retention': {
            target: targets.menuRetentionRouteTarget,
            '/*': 'beforeAll',
            '/':  {
              target: targets.menuRetentionRouteTarget,
              '/': 'index'
            }
          },

This is really only a problem with the '/*' route right?

I believe it occurs because we match /* and then stop matching on the same level, requiring the nested / definition to be picked-up.

Wondering if this is actually what we want.

Having 2 actions match on the same route level, will not ensure execution order, unless we special case the '/*' route.

That's a good point, and it's now easier to write given the target ancestor fallback you recently merged:

          '/retention': {
            target: targets.menuRetentionRouteTarget,
            '/*': 'beforeAll',
            '/':  {
              '/': 'index'
            }
          },

The non-obvious part is having to specify '/' twice. How could we make that more intuitive?

I wonder if we should allow this instead:

'/retention': {
  target: targets.menuRetentionRouteTarget,
  '/': ['beforeAll', 'index']
}