observ-history

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i observ-history

Weekly Downloads

1

Version

1.0.3

License

MIT

Last publish

Collaborators

  • bendrucker