npm.io
1.0.3 • Published 10 years ago

observ-history

Licence
MIT
Version
1.0.3
Deps
4
Vulns
0
Weekly
0
Stars
4

observ-history Build Status

Observable interface to the browser history API

Install

$ npm install --save observ-history

Usage

var history = require('observ-history')

history(function (path) {
  //=> (popstate)  
})

history()
//=> current path

history.set(path)
//=> pushState

API

history([listener]) -> function

Returns an unlisten function.

listener

Type: function

A function to call with the current path when the history changes and a popstate event is fired. If no function is passed, the current path is returned.

history.set(path) -> undefined

Updates the history by calling pushState.

License

MIT Ben Drucker

Keywords