1

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?

romainberger
  • 4,563
  • 2
  • 35
  • 51

0 Answers0