More interfaces? feedback from aurelia 1 for 2

I know aurelia is convention oriented, but are there more interfaces hiding somewhere? example, I have this

@connectTo()
@autoinject()
export class App {

  constructor(
    private router: Router,
    private readonly store: Store<State>,
    private readonly stateHolder: StateHolder,
  ) {
  }

  configureRouter(config: RouterConfiguration, router: Router) {
    config.title = 'WarMeister';
    config.map([
      {
        route: ['', 'home'],
        name: 'home',
        viewPorts: {
          main: { moduleId: PLATFORM.moduleName('roster/GameRosterNav') },
        },
      },
      {
        route: 'games',
        name: 'games',
        title: 'Add Game',
        viewPorts: {
          main: { moduleId: PLATFORM.moduleName('game/index') },
        }
      },
//      { route: ':user/rosters/:game', name: 'rosters', moduleId: PLATFORM.moduleName('roster/GameRosterNav'), title: 'Roster' },
    ]);

    this.router = router;
  }
  
  async attached() {
    return this.store.state.subscribe((state) => {
      console.log('state', state);
      this.stateHolder.state = state;
    });
  }

but what I’d really like is

@connectTo()
@autoinject()
export class App implements RouterConfigurer, AttachListener {

  constructor(
    private router: Router,
    private readonly store: Store<State>,
    private readonly stateHolder: StateHolder,
  ) {
  }

  configureRouter(config: RouterConfiguration, router: Router) {
    config.title = 'WarMeister';
    config.addRoutes([ // currently .map is very week, and doesn't really say which keys are available and typos are very easy.
      {
        route: ['', 'home'],
        name: 'home',
        viewPorts: {
          main: { moduleId: PLATFORM.moduleName('roster/GameRosterNav') },
        },
      },
      {
        route: 'games',
        name: 'games',
        title: 'Add Game',
        viewPorts: {
          main: { moduleId: PLATFORM.moduleName('game/index') },
        }
      },
//      { route: ':user/rosters/:game', name: 'rosters', moduleId: PLATFORM.moduleName('roster/GameRosterNav'), title: 'Roster' },
    ]);

    this.router = router;
  }
  
  async attached() {
    return this.store.state.subscribe((state) => {
      console.log('state', state);
      this.stateHolder.state = state;
    });
  }

is this already possible? should I open a bug requesting for v2? would v1 backport patches be welcome?

3 Likes

Here’re the relevant interfaces for router that you can implement:

Here’re the ones for templating:

3 Likes

We already have exhaustive interfaces in v2 for this sort of thing as well :slight_smile:

2 Likes

yeah, I think in v1 this was just a doc problem.

2 Likes

Until about a year ago when I stumbled onto those source files, I was unaware of these v1 interfaces - I had been creating my own.

1 Like

I had been creating my own.

:sweat: