Skip to content

bendrucker/observ-history

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

observ-history Build Status Greenkeeper badge

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

About

Observable interface to the browser history API

Resources

License

Stars

Watchers

Forks

Packages

No packages published