routeemitter
v0.1.0-rc3
Published
Isomorphic url router to (a) abstract urls as `Route`s, and (b) track and manipulate a "current" route, optionally (and by default) binding to document location on browser
Downloads
6
Maintainers
Readme
routeemitter
Isomorphic url router to (a) abstract urls as Route
s, and (b) track and manipulate a "current" route, optionally (and by default) binding to document location on browser
documentation
installation
npm install --save routeemitter
example
var RouteEmitter = require('routeemitter');
var presenter = require('./presenter');
var api = require('./api');
var router = new RouteEmitter({
home: '/',
blog: '/blog(/tag/:tag)(/:slug)',
contact: '/contact'
}, {/* options... */});
router.on('route', function(route, old_route){
presenter.updatePage(route, old_route);
if (route.name=='blog'){
if (route.params.tag){
api.getBlogsByTag(route.params.tag).then(function(blogs){
presenter.updateBlogList(blogs);
});
}
if (route.params.slug){
api.getBlogBySlug(route.params.tag).then(function(blog){
presenter.updateCurrentBlog(blog);
});
}
}
});
changelog
0.1.0
- Initial release as RouteEmitter