1.0.4 • Published 4 years ago

url-vuex-sync v1.0.4

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

url-vuex-sync

This plugin syncs route query with specific params from Vuex state.

For example:
You can have a route like '/products?type=fruits'
And a param in vuex state "type".
Plugin helps to sync them, so every time url param changes - the store is being update and vice versa.

Usage

npm i url-vuex-sync
import sync from 'url-vuex-sync'
import store from './store' // your Vuex store
import router from './router' // your router

sync(store, router, [
  {
    name: 'stateParam', // state param or getter that should by synced
    as: 'aliasForUrl', // alias for url, not required
    mutation: 'setParam' // mutation
  }
]);

How does it work

Firstly it moves all synced params from route query to vuex state. Then it applies watchers on them, so every time state changes the route is being update.

License

MIT

1.0.4

4 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago