Skip to content

Repository files navigation

router

Simple client-side router.

Installation

$ component install component/router

Examples

Example with only setup callbacks:

varRouter=require('router');varrouter=newRouter;router.get('/user/:id',function(id){console.log('show %s',id);});router.dispatch('/user/2');

Setup and teardown callbacks for unbinding events etc:

varRouter=require('router');varrouter=newRouter;router.get('/user/:id',function(id){console.log('show %s',id);},function(id){console.log('hide %s',id);});router.dispatch('/user/2');router.dispatch('/user/5');router.dispatch('/user/10');

Fluent api equivalent of above:

varRouter=require('router');varrouter=newRouter;router.get('/user/:id').before(function(id){console.log('show %s',id);}).after(function(id){console.log('hide %s',id);});router.dispatch('/user/2');router.dispatch('/user/5');router.dispatch('/user/10');

License

MIT

About

Simple client-side router

Resources

Stars

31 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages