@mizchi/router

0.0.2 • Public • Published

Router

Router for minimalist

npm install @mizchi/router --save

for pushstate

Router = require '@mizchi/router'
router = new Router
router.route 'users/:name', (params) ->
  console.log params.name

# listening events is your task 

window.addEventListener 'DOMContentLoaded', ->
  router.emit(location.pathname)

window.addEventListener 'pushstate', -> router.emit(location.pathname)
window.addEventListener 'popstate', -> router.emit(location.pathname)

for hashchange

Router = require '@mizchi/router'
router = new Router(hash: true)
router.route 'users/:name', (params) ->
  console.log params.name

window.addEventListener 'DOMContentLoaded', ->
  router.emit(location.hash)

window.addEventListener 'hashchange', ->
  router.emit(location.hash)

Readme

Keywords

none

Package Sidebar

Install

npm i @mizchi/router

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • mizchi