import Router from '@cubex/router';
class Application {
router: Router = new Router();
constructor() {
/*
* Sets Default Route
*/
this.router.setDefaultRoute(function () {
console.log('Route: Default');
});
/*
* Set Error Route
*/
this.router.setErrorRoute(function () {
console.log('Route: Default');
});
/*
* Set Route and exit function
*/
this.router.addRegex('test', function () {
console.log('Route: Test');
}, function(newHash: string) {
console.log('Route Exit: Test, New Hash: ' + newHash);
});
/*
* Set Route with parameter
*/
this.router.addRegex('test/:id', function (id) {
console.log('Route: Test, id: ' + id);
});
/*
* Set Route with two parameters defined by function
*/
this.router.addFunction('test', function (id, name) {
console.log('Route: Test, id: ' + id + ', name: ' + name);
});
}
/*
* Start Router, with option to defer run until route change
*/
start(defer: boolean = false) {
this.router.start(defer);
}
/*
* Stop Router
*/
stop() {
this.router.stop();
}
}
-
Notifications
You must be signed in to change notification settings - Fork 0
A simple hash routing utility
License
Cubex30/router
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A simple hash routing utility
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published