Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing Middleware #531

Open
1 task
agubler opened this issue Sep 11, 2019 · 0 comments
Open
1 task

Routing Middleware #531

agubler opened this issue Sep 11, 2019 · 0 comments
Labels
area: core Core area: routing Routing enhancement New feature or request next Issue/Pull Request for the next major version

Comments

@agubler
Copy link
Member

agubler commented Sep 11, 2019

Enhancement

A routing middleware that can be used to:

  • conditionally render content based on the an outlet
  • create links
  • determine whether an outlet is active
  • provide path and query params.

Possible example usage for routing middleware:

const factory = create({ routing });

const MyWidget = factory(function MyWidget({ middleware: { routing } }) {
  let node: any = undefined;
  if (routing.isExact("home")) {
    return <div>bar menu</div>;
  }
  if (routing.isMatch("details")) {
    const { params, queryParams } = routing.getParams("details");
    return (
      <div>
         <span>{JSON.stringify(queryParams)}</span>
         <span>{JSON.stringify(params)}</span>
      </div>
    );
  }
  if (routing.isMatch("about")) {
    return <div>about</div>;
  }
  return null;
});

The middleware could be a factory to that accepts routing configuration to be registered, falling back to using a router defined as an injector, this would provide backwards compatibility with applications that are using class-based widgets.

Additional consideration(s):

  • Support for route based code splitting
@agubler agubler added enhancement New feature or request next Issue/Pull Request for the next major version area: core Core area: routing Routing labels Sep 11, 2019
@agubler agubler mentioned this issue Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Core area: routing Routing enhancement New feature or request next Issue/Pull Request for the next major version
Projects
None yet
Development

No branches or pull requests

1 participant