Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

StaticRouter

Tordeur Kenny edited this page Oct 20, 2016 · 2 revisions

Static Router

LayerJs contains a bunch of routers. The StaticRouter is one of them. With the staticRouter you can define static routes in your webpage. A route is constructed using an url and an array of frame paths (see State representation).

When the StaticRouter is passed in an url, it will look if it has a route defined for this url. If it can find a route, it will apply that state to the webpage using the state object. If it doesn't have a route defined, the router module will go to the next defined router.

The StaticRouter is always the first router that will called to handle a specific url. When other routers succesfully handled a url, they will register this url and it's associated state with the StaticRouter.

Defining a static route

The router module offers a method that can be used to define your own static route.

layerJS.router.addStaticRoute(url, state, modify)

  • url: url of the route
  • state: a state (array of strings) to link to the passed in url
  • modify: when true, existing route will be overwritten with this new route
Clone this wiki locally
Morty Proxy This is a proxified and sanitized view of the page, visit original site.