1.2.0 • Published 9 years ago

param-store v1.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

param-store

param-store manage the url. What's special about it is it treats url as independent params which can be set and get.

Travis build status npm semantic-release Dependency Status devDependency Status

API

ParamStore

import ParamStore from 'param-store'

// path is a special param in the sense that it is the path in the url
// instead of in the query part.
// Otherwise it is the same as other query params.

// SETTER
// `set` MERGE the new params with the previous params in the url
ParamStore.set({path: 'login'}) // change path
ParamStore.set({userId: 'f38adfn'}) // change userId
ParamStore.set({path: 'user', userId: 'f38adfn'}) // change path and userId
// `setAll` RESETS the whole url and ignore the previous url
Paramstore.setAll({path: 'login'}) // overwrite current params
// Options:
// options apply to set and setAll as the second argument
// replaceState: replace instead of push to history stack
// e.g.
ParamStore.set({ path: 'login' }, {replaceState: true})

// GETTER
ParamStore.get('path') // get 'path' from params
ParamStore.getAll() // get whole params object

// LISTENNER
const listener = ParamStore.listen('path', 'tab', function(report){
  const {changedParams, currentParams, previousParams} = report
})
ParamStore.unlisten(listener)

connect

import {connect} from 'param-store'

connect(Login, 'path', 'tab’) // path and tab will be passed as props

Link

// Link use `setAll` under the hood
import {Link} from 'param-store'

<Link type='button' params={{path: 'about'}}>this is an anchor tag</Link>

DEVELOPMENT

  • test

    npm run browser
  • build: NOTE: before buiding, remove node_modules/history

1.2.0

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.4.9

9 years ago

0.4.8

10 years ago

0.4.7

10 years ago

0.4.6

10 years ago

0.4.5

10 years ago

0.4.4

10 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago