Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

refactor: move route configuration to a property of the component constructor #129

@btford

Description

@btford

WIP: this is something I'm still considering – feedback welcome (yo @PascalPrecht )

I think this would solve several problems, so I'm proposing it as a general solution.

Rationalle

Right now, the set of components that we need to instantiate is dynamically built up on the client. Each component only knows how to map its own level of routing. This is great, because it means we can easily re-mount and reuse routable components.

But in order to open the door for the possibility of server-side rendering, there needs to be a way to statically map a URL to the set of components it needs. This is important that this mapping is static and declarative. This is because some apps might not want to run JS code for router components on the server – like apps which are not written with node.

It's also important so that a parent component can link to a child component. Right now, this is broken.

Other routing systems avoid this problem by consolidating all routing information into a single place before the app bootstraps. This solution is good, but it loses some of the benefits of our earlier approach.

Concrete example of the problem

TODO

Implementation

This is what an app would look like in 1.x:

Before:

function MyController($router) {
  $router.config([ ... ]);
  /* controller init */
}

After:

MyController.$router = [ ... ];
function MyController() {
  /* controller init */
}

With AtScript, you could use annotations to make this a little prettier:

@router([ ... ])
class MyComponent() { ... }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions