Index

routeemitter 0.1.0-rc3

routeemitter

Isomorphic url router to (a) abstract urls as Routes, and (b) track and manipulate a "current" route, optionally (and by default) binding to document location on browser

build status dependencies dev-dependencies

npm

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

Documentation generated by JSDoc 3.3.0-alpha5 on Tue Jun 09 2015 02:21:38 GMT-0400 (Eastern Daylight Time) using the DocStrap template.