-
Notifications
You must be signed in to change notification settings - Fork 81
StaticRouter
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.
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