observ-path

1.0.2 • Public • Published

observ-path Build Status

Observable interface to the browser path with history support

Install

$ npm install --save observ-path

Usage

var Path = require('observ-path')
 
var path = Path('/the/initial/path')
 
path(console.log)
//=> path changed
 
path.set('/the/new/path')
//=> path updated and history entry added

API

Path([value]) -> function

Returns an observable path.

value

Type: string
Default: ''

The initial path, defaulting to document.location.pathname in the browser and '' in Node.

path([fn]) -> function / string

fn

Type: function

A function to call when the path changes. If no function is provided, the current value is returned.

path.set(value) -> undefined

value

Required
Type: string

The new path value to set.

License

MIT © Ben Drucker

Package Sidebar

Install

npm i observ-path

Weekly Downloads

3

Version

1.0.2

License

MIT

Last publish

Collaborators

  • bendrucker