dojo / dojo/framework

Routing Middleware

Open
#531 0 comments 1 reaction 0 assignees View on GitHub
area: core area: routing enhancement next
Dominant language
TypeScript
Stars
623
Forks
78
PR merge metrics
No merged PRs in 30d

Description

**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:

```tsx
const factory = create({ routing });

const MyWidget = factory(function MyWidget({ middleware: { routing } }) {
let node: any = undefined;
if (routing.isExact("home")) {
return

bar menu
;
}
if (routing.isMatch("details")) {
const { params, queryParams } = routing.getParams("details");
return (

{JSON.stringify(queryParams)}
{JSON.stringify(params)}

);
}
if (routing.isMatch("about")) {
return
about
;
}
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.