@yuheiy/simple-url-dispatcher
v0.2.1
Published
The dispatcher to divide methods of client-side JavaScript according to URL.
Downloads
1
Readme
Simple URL Dispatcher
The dispatcher to divide methods of client-side JavaScript according to URL.
Installation
$ npm install @yuheiy/simple-url-dispatcher --save
Usage
var Dispatcher = require('@yuheiy/simple-url-dispatcher');
var dispatcher = new Dispatcher();
dispatcher.route('*', function () {
console.log('run on all pages');
});
dispatcher.route('/', '/index.html', function () {
console.log('index');
});
dispatcher.route('/about', function () {
console.log('about');
});
dispatcher.route('/user/:id', function (params) {
console.log('user', params.id);
});
// run url methods
dispatcher.run();