This package has been deprecated

Author message:

Not maintained anymore. Package name available!

pather

0.0.12 • Public • Published

Pather.js

Subscribe to changes in window.location

Build Status

Disclaimer: This is work in progress

Works in browsers supporting the HTML5 History API, for older browsers, a polyfill like devote/HTML5-History-API is required.

Examples

Simple

Pather.on("/foo/bar", function() {
  console.log("Enter /foo/bar");
})
 
window.history.pushState({}, null, "/foo/bar")

Named parameters (Sinatra/Backbone style)

Pather.on("/foo/:a/:b", function(a, b) {
  console.log("Enter /foo/"+a+"/"+b);
})
 
window.history.pushState({}, null, "/foo/bar/baz")

You can also match against the location hash:

Try in jsfiddle

Pather.on("/fruits/:fruit/#:bookmark", function(fruit, bookmark) {
  console.log('Now display the "%s" section of the page about the "%s"', bookmark, fruit);
});
 
window.history.pushState({}, null, "/fruits/banana/")
window.location.hash = "nutrition_facts"

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i pather

    Weekly Downloads

    0

    Version

    0.0.12

    License

    MIT

    Last publish

    Collaborators

    • bjoerge