I'm trying to use routerjs as a standalone library but can't figure out how to implement the handler lookup as it's said in the documentation, and couldn't find any example.
What I've got so far:
var router = new Router['default']()
router.map(function(match) {
match('/').to('index')
match('/chat').to('chat')
})
I've tried using callbacks in the routes like this, but every callback are called not matter what url I am on so I'm not sure how to use it:
router.map(function(match) {
match('/').to('index', function() {
console.log('always called')
})
match('/chat').to('chat', function() {
console.log('always called as well')
})
})
Has anybody successfully used it?