0.1.4 • Published 3 years ago

@tofandel/hash-router v0.1.4

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
3 years ago

@tofandel/hash-router

Build coverage npm version dependencies

A frontend router for the hash change event

Example

import HashRouter from "@tofandel/hash-router";

const router = new HashRouter({
  '/': renderHome,
  '/login': showLoginDialog,
  '*': fallbackRoute
})
router.addRoute('/another', anotherRouteCb);

router.on("routed", function (hash, event) {
  console.log("Route has changed!", hash, event)
})
router.on("not-found", function (hash, event) {
  console.log("Didn't find a route", hash, event) // This won't ever fire if the '*' route is set
})

router.started.then(() => {
  console.log('Router is ready');
  router.go('/login');
})

Installation

npm install @tofandel/hash-router

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago