observ-location-hash
v1.0.2
Published
Observable interface to the browser hash location
Downloads
20
Maintainers
Readme
observ-location-hash
Observable interface to the browser hash location
Install
$ npm install --save observ-location-hash
Usage
var ObservHash = require('observ-location-hash')
var hash = ObservHash('/initial-path')
hash(function (hash) {
//=> (called on window's hashchange event)
})
hash()
//=> returns current hash, minus '#' character
hash.set(path)
//=> sets current hash
API
ObservHash([initialPath])
-> observHash
observHash([listener])
-> function
Returns an unlisten function.
listener
Type: function
A function to call with the current path when the hash changes.
observHash.set(path)
-> undefined
Updates window.locaion.hash.
Related
License
MIT © Andrew Joslin