0.2.2 • Published 4 years ago

query-params-data v0.2.2

Weekly downloads
50
License
MIT
Repository
github
Last release
4 years ago

query-params-data

Actions Status

npm.io

Easily control data in query params.

  • set data at a specific query param
  • subscribe to changes of data at different query param keys.

Usage

import UrlStore from 'query-params-data';

// control the `user_id` query param
const userIdUrlStore = new UrlStore('user_id');

// set data to the `user_id` query param
userIdUrlStore.setState('1');

// subscribe to changes of the `user_id` query param or get the existing state at startup
const onChange = state => console.log(`The current user id is ${state}`);
userIdUrlStore.subscribeToStateChanges(onChange);