Class

AdmRouter

AdmRouter(config)

---------------------------------------------------------------------------------------------- Class AdmRouter - Handling app routing ----------------------------------------------------------------------------------------------
Constructor

# new AdmRouter(config)

Create a Router.
Parameters:
Name Type Description
config object Configuration object of router

View Source router/AdmRouter.js, line 17

Example
//Example 1:
const config = {
	root: '',
	routes: [{path, config, handler}],
	listen: true,
 change: () => {}
	fail: () => {}
	initComplete =  () => {} || null;
};

const router = new AdmRouter(config);

//Example 2:
const router = new AdmRouter({root: ''});
router
	.add("/", (routeData) => { ... }, configData)
	.add("/*", (routeData) => { ... }, configData)
	.add("*", (routeData) => { console.log("404"); })
	.listen()

Methods

# _callRouteHandler(matchData)

[Private] Handle route handlers.
Parameters:
Name Type Description
matchData string result of match function

View Source router/AdmRouter.js, line 185

# add(route, config, handler) → {object}

Add a route.
Parameters:
Name Type Default Description
route string Expression of a route. For a catchall or 404 error route add an asteric ("*") as last route
config object null Configuration of a route (optional)
handler function null Handler by matching of a route (optional)

View Source router/AdmRouter.js, line 83

The router instance
object

# listen() → {object}

Listen to url changes.

View Source router/AdmRouter.js, line 123

The router instance
object

# match(path, data) → {object}

Match a route.
Parameters:
Name Type Default Description
path string Path from an url
data string null ThroughPass data (optional)

View Source router/AdmRouter.js, line 137

Match data from route
object
Match a route.
Parameters:
Name Type Default Description
path string Path to navigate
data string null ThroughPass data (optional)
title string Title from website (optional)
replace boolean false History replace - default false (optional)

View Source router/AdmRouter.js, line 169

# remove(route) → {object}

Remove a route.
Parameters:
Name Type Description
route string Expression of a route

View Source router/AdmRouter.js, line 98

The router instance
object

# removeAll() → {object}

Remove all routes.

View Source router/AdmRouter.js, line 114

The router instance
object