-
Notifications
You must be signed in to change notification settings - Fork 3
Router
Arthur Guiot edited this page May 5, 2018
·
1 revision
The Router API is a system that will help you parse a URL to dynamically switch between Views and context. With the Router API, you'll be able to handle any user request differently and individually.
To use the Router API, you'll have to use the .Router() function like:
const P = new ProType();
... // your code
P.Router(data => {
// How to handle a request
})The data object will be a set of information about the URL. Here are all the values of this object:
data.url // The full URL (ex: http://www.example.com:8080/search?q=devmo#test)
data.origin // The origin (ex: http://www.example.com:8080)
data.path // The unparsed path (ex: /search)
data.pathValue // data.path.split("/") (ex: ['search'])
data.hash // The content after '#' (including '#') (ex: #test)
data.search // An object with the search parameters (ex: { q: "devmo" })